Skip to main content
LIVE CONTEST: ALGOR Contest: Round #4 (Special Challenge) is live now!

~/algor $ cat problems/qavariq-qobiq-perimetri

Perimeter of the convex hull

Medium 1000 ms 128 MB 66%
Share

$n$ points $(x_{1}; y_{1}), (x_{2}; y_{2}), \ldots, (x_{n}; y_{n})$ are given on the plane. Find the perimeter of the smallest convex polygon containing all the points (the convex hull). If all the points lie on one line, the perimeter is taken to be twice the distance between the two extreme points.

Points on the coordinate plane and the convex polygon enclosing them

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 convex hull, with exactly $2$ digits after the decimal point (for example, 16.00).

Note

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

Examples

Input #1
5
0 0
4 0
4 4
0 4
2 2
Output #1
16.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.