Convenience Store 2
InterviewTime limit2sMemory limit512 MB
Given n customer points, place one store anywhere to minimize the total Manhattan distance to all customers and print that minimum sum.
Problem
Youngseon plans to start a convenience store. Most of the preparation is done, but the store's location is not decided yet. From market research, Youngseon knows where the main customers are, and wants to place the store so that the sum of the distances to all customers is as small as possible. The distance between two locations and is defined as .
You are given the locations of main customers. If the store is built at a location that minimizes the sum of distances to all customers, what is that minimum sum?
Input
The first line contains , the number of main customers.
Each of the next lines contains the location , of customer , separated by a space.
Output
Print the minimum possible sum of distances from the store to all customers, as an integer.
Constraints
- All input values are integers.