Problem: A root tree is a directed acyclic graph that contains one node (root), from which there is exactly one path to any other node.

A root tree is binary if each node has at most two outgoing arcs.

When a binary tree is painted on the plane, all arcs should be directed from top to bottom. That is, each arc going from u to v must meet the condition yu > yv.

You've been given the coordinates of all tree nodes. Your task is to connect these nodes by arcs so as to get the binary root tree and make the total length of the arcs minimum. All arcs of the built tree must be directed from top to bottom.

Input

The first line contains a single integer n (2 ≤ n ≤ 400) — the number of nodes in the tree. Then follow n lines, two integers per line: xi, yi (|xi|, |yi| ≤ 103) — coordinates of the nodes. It is guaranteed that all points are distinct.

Output

If it is impossible to build a binary root tree on the given points, print "-1". Otherwise, print a single real number — the total length of the arcs in the minimum binary tree. The answer will be considered correct if the absolute or relative error doesn't exceed 10 - 6. 

Examples

Input

3
0 0
1 0
2 1


Output

3.650281539872885


Input

4
0 0
1 0
2 1
2 0


Output

-1

Solution (in JAVA):

Solution:
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.ArrayList;
import java.util.Arrays;
    
    
    public class Main {
    
        private static StreamTokenizer in;

        public static void main(String[] args) {
            in = new StreamTokenizer(new InputStreamReader(System.in));
            int vertices = nextInt();
            int[][] points = new int[vertices][2];
            for (int i=0; i<vertices; i++) {
                points[i][0] = nextInt();
                points[i][1] = nextInt();
                
            }
            Graph graph = new Graph(2*vertices+2);
            for (int i=0; i<vertices; i++) {
                graph.addEdge(0, i+1, 1, 0);
                graph.addEdge(vertices+i+1, 2*vertices+1, 2, 0); 
            }
            for (int i=0; i<vertices; i++) {
                for (int j=0; j<vertices; j++) {
                    if (points[i][1] < points[j][1]) {
                        double rast = Math.sqrt((points[i][0] - points[j][0]) * (points[i][0] - points[j][0]) + (points[i][1] - points[j][1]) * (points[i][1] - points[j][1]));
                        graph.addEdge(i+1, vertices+j+1, 1, rast); 
                    }
                }
            }
            double[] flow = graph.getMaxFlow();
            if (flow[0] < vertices-1) {
                System.out.println("-1");
            } else {
                System.out.println(flow[1]); 
            }
        }

        private static int nextInt() {
            try {
                in.nextToken();
            } catch (IOException e) {
            }
            return (int) in.nval;
        }
    
    }
    
    
    
    class Graph {
        
        int vertices;
        boolean found[];
        double cap[][], flow[][], cost[][], distance[], pi[];
        ArrayList<ArrayList<Integer>> adj;
        int prev[];
        int s = 0, t;
        
        static double INF = Double.MAX_VALUE/2 - 1;

        public Graph(int vertices) {
            this.vertices = vertices;
            cap = new double[vertices][vertices];
            flow = new double[vertices][vertices];
            cost = new double[vertices][vertices];
            prev = new int[vertices];
            distance = new double[vertices+1];
            pi = new double[vertices];
            found = new boolean[vertices];
            t = vertices-1;
            adj = new ArrayList<ArrayList<Integer>>(vertices);
            for (int i=0; i<vertices; i++) 
                adj.add(new ArrayList<Integer>());
        }
        
        
        public void addEdge(int from, int to, int capacity, double cost) {
            this.cap[from][to] = capacity;
            this.cost[from][to] = cost;
            adj.get(from).add(to);
            adj.get(to).add(from);
        }
        
        boolean getRoute() {
            Arrays.fill(found, false);
            Arrays.fill(distance, INF);
            distance[s] = 0;
            int now = s;
            while (now != vertices) {
                int best = vertices;
                found[now] = true;
                for (int k = 0; k < vertices; k++) {
                if (found[k]) continue;
                if (flow[k][now] != 0) {
                    double val = distance[now] + pi[now] - pi[k] - cost[k][now];
                    if (distance[k] > val) {
                    distance[k] = val;
                    prev[k] = now;
                    }
                }
                if (flow[now][k] < cap[now][k]) {
                    double val = distance[now] + pi[now] - pi[k] + cost[now][k];
                    if (distance[k] > val) {
                    distance[k] = val;
                    prev[k] = now;
                    }
                }
                
                if (distance[k] < distance[best]) best = k;
                }
                now = best;
            }
            for (int k = 0; k < vertices; k++)
                pi[k] = Math.min(pi[k] + distance[k], INF);
            return found[t];
            }
            
            
            double[] getMaxFlow() {
            
            double totalFlow = 0, totalCost = 0;
            while (getRoute()) {
                double min = INF;
                for (int x = t; x != s; x = prev[x])
                min = Double.min(min, flow[x][prev[x]] != 0 ? flow[x][prev[x]] :
                               cap[prev[x]][x] - flow[prev[x]][x]);
                for (int x = t; x != s; x = prev[x]) {
                if (flow[x][prev[x]] != 0) {
                    flow[x][prev[x]] -= min;
                    totalCost -= min * cost[x][prev[x]];
                } else {
                    flow[prev[x]][x] += min;
                    totalCost += min * cost[prev[x]][x];
                }
                }
                totalFlow += min;
            }
            
            return new double[]{ totalFlow, totalCost };
            }
        
    }