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.InputStreamReader;
import java.io.IOException;
import java.util.*;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

public class Solution {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AC solver = new AC();
        solver.solve(in, out);
        out.close();
    }
}

class AC {
    PrintWriter out;
    final int MAXN = 1010;
    final int MAXM = 400010;
    final int inf = 1000000000;

    class Edge {
        int u, v, cap;
        double cost;
        int next;
    }

    int NE;
    int head[] = new int[MAXN], pp[] = new int[MAXN];
    double dist[] = new double[MAXN];
    boolean vis[] = new boolean[MAXN];
    Edge edge[] = new Edge[MAXM * 2];
    int x[] = new int[410];
    int y[] = new int[410];

    public void init() {
        NE = 0;
        Arrays.fill(head, -1);
        for (int i = 0; i < MAXM; i++)
            edge[i] = new Edge();
    }

    public void addedge(int u, int v, int cap, double cost)
    {
        edge[NE].u = u; edge[NE].v = v; edge[NE].cap = cap; edge[NE].cost = cost;
        edge[NE].next = head[u]; head[u] = NE++;
        edge[NE].u = v; edge[NE].v = u; edge[NE].cap = 0; edge[NE].cost = -cost;
        edge[NE].next = head[v]; head[v] = NE++;
    }

    public boolean SPFA(int s, int t, int n) {
        int i, u, v;
        Queue<Integer> Q = new LinkedList<Integer>();
        Arrays.fill(vis, false);
        Arrays.fill(pp, -1);
        Arrays.fill(dist, inf);
        vis[s] = true;
        dist[s] = 0;
        Q.add(s);
        while (!Q.isEmpty()) {
            u = Q.poll();
            vis[u] = false;
            for (i = head[u]; i != -1; i = edge[i].next) {
                v = edge[i].v;
                if (edge[i].cap != 0 && dist[v] > dist[u] + edge[i].cost) {
                    dist[v] = dist[u] + edge[i].cost;
                    pp[v] = i;
                    if (!vis[v]) {
                        Q.add(v);
                        vis[v] = true;
                    }
                }

            }
        }
        if ( dist[t] == inf  )
            return false;
        return true;
    }

    int SumFlow;

    public double MCMF(int s, int t, int n) {
        int flow = 0;
        int i;
        int minflow;
        double mincost = 0;
        while (SPFA(s, t, n)) {
            minflow = inf + 1;
            for (i = pp[t]; i != -1; i = pp[edge[i].u])
                if (edge[i].cap < minflow)
                    minflow = edge[i].cap;
            flow += minflow;
            for (i = pp[t]; i != -1; i = pp[edge[i].u]) {
                edge[i].cap -= minflow;
                edge[i ^ 1].cap += minflow;
            }
            mincost += dist[t] * minflow;

        }
        SumFlow = flow;
        return mincost;

    }

    public double distance(int u, int v) {
        return Math.sqrt( 1.0 * (x[u] - x[v]) * (x[u] - x[v]) + 1.0*(y[u] - y[v])
                * (y[u] - y[v]) );
    }

    public void solve(InputReader in, PrintWriter out) {
        int n;
        n = in.nextInt();
        for (int i = 0; i < n; i++) {
            x[i] = in.nextInt();
            y[i] = in.nextInt();
        }
        init();
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (y[i] > y[j]) {
                    // out.printf("i=%d j= %d\n",i,j);
                    addedge(i, j + n, 1, (distance(i, j)));
                }
            }
        }
        int S = 2 * n, T = S + 1;
        for (int i = 0; i < n; i++) {
            addedge(S, i, 2, 0);
            addedge(i + n, T, 1, 0);
        }
        SumFlow = 0;
        double cost = MCMF(S, T, T + 1);
        if (SumFlow != n - 1) {
            out.println("-1");
        } else
            out.printf("%.10f\n", cost);
        // this.out.close();
    }
}

class InputReader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String next() {
        if (!hasNext())
            throw new RuntimeException();
        return tokenizer.nextToken();
    }

    boolean hasNext() {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (Exception e) {
                return false;
            }
        return true;
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }
}
/*
 * 1 2 3 -10 10 0 20
 */