#P10452. 货仓选址
货仓选址
Problem Description
There are stores on a number line, with coordinates .
Now you need to build a warehouse on the number line. Every morning, one truck of goods must be delivered from the warehouse to each store.
To improve efficiency, find where to build the warehouse so that the sum of distances from the warehouse to all stores is minimized.
Input Format
The first line contains an integer .
The second line contains integers .
Output Format
Output one integer, representing the minimum possible sum of distances.
4
6 2 9 1
12
Hint
Constraints: , .
Translated by ChatGPT 5