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.util.*;
import java.io.*;
import static java.lang.System.*;
import static java.lang.Integer.*;

public class CF277E{
    static class Edge {
        int to, f, cap, rev;
        double cost;
        public Edge(int v, int cap, double cost, int rev) {
            this.to = v; this.cap = cap;
            this.cost = cost; this.rev = rev;
        }
    }
    static class Pair implements Comparable<Pair>{
        double c;
        int n;
        public Pair(int n, double c){
            this.n = n;
            this.c = c;
        }
        public int compareTo(Pair p){
            return Double.compare(c, p.c);
        }
    }
    public static List<Edge>[] createGraph(int n) {
        List<Edge>[] graph = new List[n];
        for(int i = 0; i < n; i++)
            graph[i] = new ArrayList<>();
        return graph;
    }
    public static void addEdge(List<Edge>[] g, int s, int t, int cap, double cost) {
        g[s].add(new Edge(t, cap, cost, g[t].size()));
        g[t].add(new Edge(s, 0, -cost, g[s].size()-1));
    }
    public static void bf(List<Edge>[] g, int s, double[] d) {
        int n = g.length;
        Arrays.fill(d, 0, n, Integer.MAX_VALUE);
        d[s] = 0;
        boolean[] inqueue = new boolean[n];
        int[] q = new int[n]; int qt = 0; q[qt++] = s;
        for(int qh = 0; (qh - qt) % n != 0; qh++) {
        int u = q[qh % n];
        inqueue[u] = false;
        for(int i = 0; i < g[u].size(); i++) {
        Edge e = g[u].get(i);
        if(e.cap <= e.f) continue;
        int v = e.to;
        double ndist = d[u] + e.cost;
        if(d[v] > ndist) {
        d[v] = ndist;
        if(!inqueue[v]) {
        inqueue[v] = true;
        q[qt++ % n] = v; }}}}
    }
    public static Pair minCostFlow(List<Edge>[] g, int s, int t, int maxf) {
        int n = g.length;
        int[] curf = new int[n];
        int[] prevedge = new int[n];
        int[] prevnode = new int[n];
        double[] pot = new double[n];
        double[] prio = new double[n];
        // skip if edge costs are non-negative
        bf(g, s, pot);
        int flow = 0;
        double flowCost = 0;
        while(flow < maxf) {
            Queue<Pair> q = new PriorityQueue<Pair>();
            q.add(new Pair(s, 0));
            Arrays.fill(prio, 0, n, 9999999999999999999.);
            prio[s] = 0;
            curf[s] = Integer.MAX_VALUE;
            while(!q.isEmpty()) {
                Pair cur = q.remove();
                double d = cur.c;
                int u = cur.n;
                if(Math.abs(prio[u]-d) > 1e-7) continue;
                for(int i = 0; i < g[u].size(); i++) {
                    Edge e = g[u].get(i);
                    int v = e.to;
                    if(e.cap <= e.f) continue;
                    double nprio = prio[u] + e.cost + pot[u] - pot[v];
                    if(prio[v] > nprio) {
                        prio[v] = nprio;
                        q.add(new Pair(v, nprio));
                        prevnode[v] = u;
                        prevedge[v] = i;
                        curf[v] = Math.min(curf[u], e.cap-e.f);
                    }
                }
            }
            if(prio[t] == 9999999999999999999.) break;
            for(int i = 0; i < n; i++)
                pot[i] += prio[i];
            int df = Math.min(curf[t], maxf - flow);
            flow += df;
            for(int v = t; v != s; v = prevnode[v]) {
                Edge e = g[prevnode[v]].get(prevedge[v]);
                e.f += df; g[v].get(e.rev).f -= df;
                flowCost += df * e.cost;
            }
        }
        return new Pair(flow, flowCost);
    }
    
    public static void main(String[] args)throws Exception{
        BufferedReader sc = new BufferedReader(new InputStreamReader(in));
        int n = parseInt(sc.readLine());
        
        int[] xs = new int[n];
        int[] ys = new int[n];
        int maxy = -1000;
        int occ = 0;
        for(int i=0; i<n; i++){
            StringTokenizer st = new StringTokenizer(sc.readLine());
            xs[i] = parseInt(st.nextToken());
            ys[i] = parseInt(st.nextToken());
            if(ys[i] > maxy){
                maxy = ys[i];
                occ = 1;
            }else if(ys[i] == maxy){
                occ++;
            }
        }
        
        if(occ > 1){
            out.println("-1");
            return;
        }
        
        //s == 2*n, t == 2*n+1
        List<Edge>[] graph = createGraph(2*n+2);
        //List<Edge>[] g, int s, int t, int cap, int cost
        for(int i=0; i<n; i++){
            addEdge(graph, 2*n, i*2, 2, 0);
            if(ys[i] != maxy){
                addEdge(graph, i*2+1, 2*n+1, 1, 0);
            }
            for(int j=0; j<n; j++){
                if(i == j) continue;
                if(ys[i] > ys[j]){
                    addEdge(graph, i*2, j*2+1, 1, Math.sqrt(0.0 + (xs[i]-xs[j])*(xs[i]-xs[j]) + (ys[i]-ys[j])*(ys[i]-ys[j])));
                }
            }
        }
        
        Pair ans = minCostFlow(graph, 2*n, 2*n+1, n-1);
        if(ans.n != n-1){
            out.println("-1");
        }else{
            out.println(ans.c);
        }
    }
}