# UVa 10041

## Explanation

O(${\displaystyle n^{2}}$) brute force solution clocks at about 0.080s.
O(${\displaystyle nlogn+n}$) solution where we sort the input and determine the sum of distance from each of the locations clocks at about 0.030s.
Another O(${\displaystyle nlogn+n}$) solution is to sort the input array and determine the distance from median to all.

```2
2 2 4
3 2 4 6

```

```2
4

```