Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/kopburchak-perimetri

Perimeter of a polygon

Easy 1000 ms 128 MB 33%
Share

A polygon with $n$ vertices is given on the plane: its vertices $(x_{1}; y_{1}), (x_{2}; y_{2}), \ldots, (x_{n}; y_{n})$ are listed in traversal order. Find the perimeter of the polygon — the sum of the lengths of all its sides.

A polygon with the given vertices on the coordinate plane and its sides

Input

The first line contains a positive integer $n$. Each of the next $n$ lines contains two integers: $x_{i}$ and $y_{i}$.

Output

One number — the perimeter of the polygon, with exactly $2$ digits after the decimal point (for example, 14.00).

Note

$3 \le n \le 10^{5}$
$-10^{9} \le x_{i}, y_{i} \le 10^{9}$

Examples

Input #1
4
0 0
4 0
4 3
0 3
Output #1
14.00
Input #2
3
0 0
3 0
0 4
Output #2
12.00

Sign in to submit a solution

Signing up is free and takes a minute.