I have the following function, and I need to minimize it with respect to $x$ given any constant array of positive numbers $a_0, a_1, ..., a_n$.
$$\sum_{i=0}^{n}\frac{\lvert x-a_i\rvert}{a_i}$$
I recognize that this function is composed of $n + 1$ line segments, and the minimum does lie on one of their vertices, which are fairly easy to calculate. The current method I use is just computing the function's value at each vertex, and picking the smallest one.
I am wondering if there is a way of finding the vertex with the minimum value from the constants directly without bruteforcing and computing all of the values.