Without loss of generality (wlog),
\begin{equation*}
0\le a_1\le\cdots\le a_p\le a\le a_{p+1}\le\cdots\le a_n\le b \tag{1}\label{1}
\end{equation*}
for some $p\in\{0,\dots,n\}$. Also, by approximation, wlog $f$ is strictly convex on $[a,b]$.

If $p=0$, then $a_i\ge a$ for all $i\in\{0,\dots,n\}$ and hence $b=\sum_1^n a_i\ge na$, which is impossible if
\begin{equation*}
n>b/a, \tag{2}\label{2}
\end{equation*}
which will be assumed henceforth. So, $p\ge1$. Letting now
\begin{equation*}
s:=\sum_1^p a_i \tag{3}\label{3}
\end{equation*}
and recalling that $f$ is concave on $[0,a]$, we have
\begin{equation*}
S:=\sum_{i=1}^n f(a_i)\le T:=pf(s/p)+\sum_{i=p+1}^n f(a_i). \tag{4}\label{4}
\end{equation*}

It is enough to show that
\begin{equation*}
T\le nf(b/n) \tag{5}\label{5}
\end{equation*}
for all large enough $n$.
Since $f$ is continuous on $[a,b]$, the sum $\sum_{i=p+1}^n f(a_i)$ attains a maximum over all $(a_{p+1},\dots,a_n)$ such that $a\le a_{p+1}\le\cdots\le a_n\le b$ and $\sum_{i=p+1}^n a_i=b-s$ (with $n,p,s$ fixed). In what follows, let $(a_{p+1},\dots,a_n)$ be a corresponding maximizer.

One of the following two cases takes place:

*Case 1: $a_n=b$* or *Case 2: $a_n<b$*.

Consider Case 1. Then $a_1=\cdots=a_{n-1}=0$ and $p=n-1$, whence \eqref{5} can be rewritten as
\begin{equation*}
f(b)-f(0)\le n[f(b/n)-f(0)]. \tag{6}\label{6}
\end{equation*}
We have (i) $f'\le f'(0)$ on $[0,a]$, since $f$ is concave on $[0,a]$ and (ii) $f'\le f'(b)<f'(0)$ on $[a,b]$, since $f$ is convex on $[a,b]$. Therefore and because $a<b$, we have $f(b)-f(0)=\int_0^b f'<bf'(0)$. On the other hand, $n[f(b/n)-f(0)]\to bf'(0)$ as $n\to\infty$. So, for all large enough $n$, \eqref{6} holds, and hence \eqref{5} holds.

Now Consider Case 2. Then, by the strict convexity of $f$ on $[a,b]$, at most one of the coordinates $a_{p+1},\cdots,a_n$ of the maximizer $(a_{p+1},\dots,a_n)$ can be in the interval $(a,b)$, and hence at most one of the numbers $a_{p+1},\dots,a_n$ can be in the interval $(a,b]$. So,

\begin{equation*}
T=g(s):=pf(s/p)+(n-p-1)f(a)+f(b-s-(n-p-1)a) \tag{7}\label{7}
\end{equation*}
and
\begin{equation*}
0\le s\le pa,\quad n-p-1\ge0,\quad b-s-(n-p-1)a\ge a. \tag{8}\label{8}
\end{equation*}
The last inequality in \eqref{8} means
\begin{equation}
s\le b-(n-p)a. \tag{9}\label{9}
\end{equation}
For all $t\in[0,b-(n-p)a]$ we have $t/p\in[0,a]$ (by \eqref{2}) and $b-t-(n-p-1)a\in[a,b]$, so that, by the convexity of $f$ on $[0,a]$ and the convexity of $f$ on $[a,b]$,

\begin{equation*}
g'(t)=f'(t/p)-f'(b-t-(n-p-1)a)\ge f'(a)-f'(a)=0,
\end{equation*}

so that $g$ is nondecreasing on $[0,b-(n-p)a]$. So, by \eqref{7} and \eqref{9},

\begin{equation*}
T\le g(b-(n-p)a)=pf\Big(\frac{b-(n-p)a}p\Big)+(n-p)f(a)\le nf\Big(\frac bn\Big),
\end{equation*}
since $f$ is concave on $[0,a]$ and $\frac{b-(n-p)a}p\in[0,a]$ (by \eqref{8} and \eqref{2}).
Thus, \eqref{5} holds in Case 2 as well. $\quad\Box$