Calculate the Fence Needed

No attempts yetTime limit1sMemory limit128 MB

Problem

The great farmer has decided to build a fence around his farm. The farm is a group of unit squares on a grid joined edge to edge, and it has no holes inside. The farmer wants to know how long the fence must be to surround the whole farm.

Given the positions of all the unit squares, compute the perimeter of the farm. For example, a farm built from 3 unit squares in an L shape has perimeter 8.

Input

The input holds several test cases. Each test case starts with a line containing one integer NN (1N10001 \le N \le 1000), the area of the farm. Each of the next NN lines contains two space separated integers xx and yy (0x,y1000 \le x, y \le 100), the coordinates of the lower left corner of one unit square of the farm. The input ends with a line containing a single 0, and that line must not be processed.

Output

For each test case, print one integer, the perimeter of the farm. Write the result of the iith test case on the iith line of the output.