Proving that a specific value is taken by a continuous function Let $f:x\longmapsto \dfrac 1n \displaystyle\sum_{k=1}^n |x - a_k|$ where $a_k$ are elements of the interval $[0,1]$ satisfying $a_1<a_2<\cdots <a_n$.
The question asks to prove that $f$ takes the value $\dfrac{a_1+a_n}{2}$
I tried using IVT by proving that $\dfrac{a_1+a_n}{2}$ lies between two known taken values of $f$ but I didn't achieve any  progress.
Some remarks : 
$$f(0) + f(1) = 1$$
$$f(a_1)=f(0)-a_1$$
$$f(a_n)=a_n-f(0)$$
Any hints would be appreciated.

Note that $f(x)$ is convex, hence
$$
f\left(\frac{a_1 + a_n}{2}\right) \leq \frac{f(a_1) + f(a_n)}{2} = \frac{a_n - a_1}{2} \leq \frac{a_1 + a_n}{2}.
$$ 
Also, we have
$$
f(2) \geq 1 \geq \frac{a_1 + a_n}{2}.
$$
Then from IVT there exists $\xi \in \left[\frac{a_1 + a_n}{2}, 2\right]$ such that $f(\xi) = \frac{a_1 + a_n}{2}$.
