题目描述
Problem Description
Eito-kun will start attending in-person classes at Kyoto University from the second semester.
Since the first semester was entirely online, Eito-kun is not familiar with the university's layout.
Therefore, he wants to estimate the time it takes to move between classrooms in advance.
You are given the coordinates of $ N $ classrooms. The coordinates of the $ i $-th classroom are $ (x_i, y_i) $.
Assuming you start at the $ 1 $-st classroom, calculate the total distance traveled when moving sequentially to the $ N $-th classroom.
The distance from coordinates $ (a, b) $ to coordinates $ (c, d) $ is given by $ |a - c| + |b - d| $.
Input Format
The input is given from the standard input in the following format:
$ N $ $ x_1 $ $ y_1 $ $ x_2 $ $ y_2 $ $\vdots$ $ x_N $ $ y_N $
Output Format
Output the total distance traveled from the $ 1 $-st classroom to the $ N $-th classroom in one line.
Sample Input and Output
Sample Input #1
3
1 2
2 3
4 6
Sample Output #1
7
Sample Input #2
1
0 0
Sample Output #2
0
Sample Input #3
4
-2 3
1 4
5 2
4 -2
Sample Output #3
15
Notes/Hints
Constraints
- $1 \leq N \leq 100$
- $-100 \leq x_i, y_i \leq 100$ $(1 \leq i \leq N)$
- All inputs are integers.
Sample Explanation 1
The distance between the $ 1 $-st and $ 2 $-nd classrooms is $ |1 - 2| + |2 - 3| = 2 $, and the distance between the $ 2 $-nd and $ 3 $-rd classrooms is $ |2 - 4| + |3 - 6| = 5 $. Therefore, the total distance traveled is $ 2 + 5 = 7 $.
Sample Explanation 2
Since there is only one classroom, no movement is necessary.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分