marks the set of numbers P={P1,P2,P3,..,Pn}
need to find number X:
|P1-X|+|P2-X|+...+|Pn-X|=D, which minimizes D.
the fact that X is the median can be shown using induction on the number of numbers n in P.
Base: n=1: trivial to see that the median is P1 and |P1-P1|=D=0 is minimal (D>=0).
now suppose that this holds for all P of size |P|=n, we need to show that this holds for |P|=n+1.
In other words:
given that |P1-X|+|P2-X|+...+|Pn-X|=D is minimal when X=Pm is the median of P={P1,..,Pn} show that |P1-X|+|P2-X|+...+|Pn-X|=D is minimal when X=Pm' is the median of P={P1,..P(n+1)).
notice that there are two cases m'=m+1 (n is even) or m'=m (n is odd).
I suggest drawing a simple example using n=3 and n+1=4 on an axis. Can you see why this must hold?