Convenience Store 2

Given n customer points, place one store anywhere to minimize the total Manhattan distance to all customers and print that minimum sum.

Medium5MathSortingGreedyGeometryInterviewNo attempts yetTime limit2sMemory limit512 MB

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 (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) is defined as x1x2+y1y2|x_1 - x_2| + |y_1 - y_2|.

You are given the locations (xi,yi)(x_i, y_i) of nn 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 nn, the number of main customers.

Each of the next nn lines contains the location xix_i, yiy_i of customer ii, separated by a space.

Output

Print the minimum possible sum of distances from the store to all customers, as an integer.

Constraints

  • 1n1000001 \le n \le 100\,000
  • 1000000xi,yi1000000-1\,000\,000 \le x_i, y_i \le 1\,000\,000
  • All input values are integers.