{"raw_statement":[{"iden":"problem statement","content":"On the $xy$\\-plane, there are $N$ points labeled $1, 2, \\dots, N$. The coordinates of point $i$ ($1 \\le i \\le N$) are $(X_i, Y_i)$.\nThere is a robot at the origin of this plane. Your task is to control the robot to visit all the points $1, 2, \\dots, N$ **in this order**.\nThe robot has a string variable $S$, which is initially an empty string.  \nYou can move the robot using the following four types of operations:\n\n*   Operation $1$: Increase the robot's $x$ coordinate by $1$ and append `X` to the end of $S$. This operation costs $1$.\n*   Operation $2$: Increase the robot's $y$ coordinate by $1$ and append `Y` to the end of $S$. This operation costs $1$.\n*   Operation $3$: Decrease the robot's $x$ coordinate by $1$ and remove the last character of $S$. This operation can only be performed if the last character of $S$ is `X`. This operation costs $0$.\n*   Operation $4$: Decrease the robot's $y$ coordinate by $1$ and remove the last character of $S$. This operation can only be performed if the last character of $S$ is `Y`. This operation costs $0$.\n\nFind the minimum cost required for the robot to visit all points $1, 2, \\dots, N$ in this order."},{"iden":"constraints","content":"*   All input values are integers.\n*   $1 \\le N \\le 500$\n*   $0 \\le X_i, Y_i \\le 10^9$"},{"iden":"input","content":"The input is given from Standard Input in the following format:\n\n$N$\n$X_1$ $Y_1$\n$X_2$ $Y_2$\n$\\vdots$\n$X_N$ $Y_N$"},{"iden":"sample input 1","content":"2\n3 3\n1 2"},{"iden":"sample output 1","content":"6\n\nBy performing Operation $1$ once, Operation $2$ three times, and Operation $1$ twice, you can reach point $1$.  \nThen, by performing Operation $3$ twice and Operation $4$ once, you can reach point $2$.\nThe total cost of this sequence of operations is the sum of the number of times Operations $1$ and $2$ are performed, which is $6$."},{"iden":"sample input 2","content":"3\n2 2\n3 3\n1 3"},{"iden":"sample output 2","content":"7"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}