SP6578 SEGTREE - Segment Tree

Description

It was Arbor Day. Alice implemented an [RB-tree](http://en.wikipedia.org/wiki/Red-black_tree), Bob composed a [segment tree](http://en.wikipedia.org/wiki/Segment_tree), I made a [binary tree](http://en.wikipedia.org/wiki/Binary_tree) - we all have a bright outlook. Lambda is always making mistakes while implementing segment trees (See his history of submissions). He then decides to draw a "segment tree". He puts _n_ points on a plane, link certain pairs of them to form segments and all the segments form a tree. As a normal tree, it satisfies the following conditions: 1. Consider points as vertices, segments as edges, it forms a [rooted tree](http://en.wikipedia.org/wiki/Tree_%28graph_theory%29). 2. Each node _u_ is **strictly higher** than its parent, namely _y $ _{u} $_ > _y_ $ _{parent_of_u} $ . 3. Segments may only intersect on their endpoints. Lambda wants to minimize the total length of segments. **The tree can be rotated to satisfy above conditions.**

Input Format

First line of input contains single integer _n_ (1 n Next _n_ lines each contain two integers _x $ _{i} $_ , _y $ _{i} $_ denoting the coordinate of _i_-th point (0 x $ _{i} $ , _y $ _{i} $_

Output Format

The one and only line contains a real number representing the minimum length. Your answer must be rounded up to 4 digits after the decimal point.