Algorithms and Data Structures

Mouse clicks

You are doing a very manual job of copy-pasting items on a website. As you’re bored, you decide to calculate the minimum distance you need to move the mouse during the task to complete it. You know that you need to make n clicks and the exact coordinate of each click on a screen . You decide to write a program that would print the minimum distance you’ll move your mouse to complete the task in the given order. As a reminder, to calculate the distance between two points and :

Input

The first line of the input contains a single integer n (1 ≤ n ≤ ) the number of mouse clicks. The next n lines contain the floating-point coordinates of the mouse clicks that need to happen . Assume that the mouse is initially at the coordinate .

Output

The program should print the minimum distance you should move your mouse to complete the task.

Examples

Input
Output
3 0 0 0 1 1 1
2
 

Constraints

Time limit: 0.2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue