Coins

아직 제출이 없습니다시간 제한1초메모리 제한128 MB

문제

You are given an N×NN\times N matrix and in exactly NN of its cells there is a single coin.  You are going to play a game on this matrix where in one turn you can take a coin and move it to any adjacent cell. Two cells are adjacent if they share a side. However, during these moves, no two coins may occupy the same cell at the same time. Your goal is to make every row and column contain exactly one coin in as few moves as possible. Determine the minimum number of moves required.

입력

In the first line of input is the number NN (N200000N\leq 200000): the number of rows, columns and coins.

In the (i+1)(i+1)-th line are two integers r_ir\_i and c_ic\_i, denoting the initial row and column of the ii-th coin.  It is guaranteed that all pairs (r_i,c_i)(r\_i,c\_i) are different.

출력

Print a single integer: the minimum number of moves required to win at the game.