#t265. 士兵站队

士兵站队

Soldiers in a Line

Problem Description

On a playground divided into a grid, nn soldiers stand scattered on grid points, represented by integer coordinates (x,y)(x, y).

A soldier can move one step up, down, left, or right along the grid edges, but at any moment at most one soldier may occupy a given grid point.

By the officer's command, they must form a neat horizontal line, that is, stand at (x,y),(x+1,y),…,(x+n−1,y)(x,y), (x+1,y), \ldots, (x+n-1,y). Find the values of xx and yy that minimize the total number of steps the soldiers must move to line up.

Input Format

The first line of input is an integer, the number of soldiers nn.

Lines 22 through n+1n+1 each contain two integers; the (i+1)(i+1)-th line's xi,yix_i, y_i are the coordinates of the ii-th soldier.

Output Format

Output one integer on a line: the answer (the minimum total number of moves).

Sample Input

5
1 2
2 2
1 3
3 -2
3 3

Sample Output

8

Hint

For 100%100\% of the data: 1≤n≤100001 \le n \le 10000, −10000≤x,y≤10000-10000 \le x, y \le 10000.