For $n$ scalars $a_1,...,a_n$, find the solution of $$\min_{x \in \mathbb R}\sum^n_{i=1} |x - a_i|$$ I denoted $$\delta(x) = \sum^n_{i=1} |x - a_i| $$ and found $$ \delta'(x) = \sum^n_{i=1} \frac{x-a_i}{|x - a_i|}$$
However, this function is not convex so just finding the critical points won't help. In any case, I still attempted it and got to the following equation $$\mathbf b^T \mathbf c= \mathbf b^T \mathbf a $$ where $$ \mathbf a = \begin{bmatrix} a_1 \\ \vdots \\ a_n \\ \end{bmatrix}, \mathbf b = \begin{bmatrix} \frac {1}{c+a_1} \\ \vdots \\ \frac {1}{c+a_n} \\ \end{bmatrix}, \ \mathbf c = \begin{bmatrix} c \\ \vdots \\ c \\ \end{bmatrix}, $$ with $c$ being such that $$ \delta' (c) = 0$$
I am not sure if I am going in the right direction and if there is a straightforward method for approaching this problem.