Puzzle: Minimum total distance to few points on the same straight line You have 9 friends living on a straight street in houses: A,B,C,..,H,I

The distance from the beginnig of the street(from the left) for each house is:
    A– 1.1 km
    B – 2.3 km
    C – 3.0 km
    D – 4.2 km
    E – 5.1 km
    F – 6.3 km
    G – 13.4 km
    H – 19.1 km
    I – 27.5 km
You would like to buy a house at point X that: dist(A,X) + dist(B,X) + … + dist(I,X) is minimum possible value. 
I need to find X. I could do it by java program but it will not give precise answer.
Predicted solution:
In my opinion X is center of mass(centroid) for points A,B,C,...,H,I which is just average and it is true because of center of mass' definition:

The center of mass is the unique point at the center of a distribution
  of mass in space that has the property that the weighted position
  vectors relative to this point sum to zero. In analogy to statistics,
  the center of mass is the mean location of a distribution of mass in
  space.

Am I right?

You are looking for global minima for $|x-a_1|+|x-a_2|+|x-a_3|+...|x-a_9|$. Clearly, this will lie on the middle,i.e. $a_5$.
A graph for smaller case would make it clear : 
Graph is for $|x-1|+|x-2|+|x-5|$

You can prove it by making cases for $x$ and then writing the expression as a linear one. You will see that it is decreasing till middle one and then increasing.
What you have have found is minima of $|x-a_1+x-a_2+...x-a_9|$ because the centre of mass uses displacement, not distance. 
