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.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        new Solution().run();
    }
}



final class Solution implements Runnable {

    final static class Nim {
        public int index;
        public long g;
        public int cnt;
        public int lineType;

        public Nim(int index, int cnt, long g, int lineType) {
            this.index = index;
            this.cnt = cnt;
            this.g = g;
            this.lineType = lineType;
        }

        public long getGrungy() {
            if (cnt % 2 == 0)
                return 0;
            else
                return g;
        }
    }

    final static class Event implements Comparable<Event> {
        public int pos;
        public int delta;

        public Event(int pos, int delta) {
            this.pos = pos;
            this.delta = delta;
        }

        @Override
        public int compareTo(Event o) {
            return pos - o.pos;
        }
    }

    double INF = 1e10;
    int OFFSET = 5000;

    int solve() throws Throwable {

        int n = in.nextInt();
        int[] pointsX = new int[n + 1];
        int[] pointsY = new int[n + 1];
        int[] yCount = new int[2 * OFFSET];
        int yMaxI = 0;
        for (int i = 0; i < n; i++) {
            pointsX[i] = in.nextInt();
            pointsY[i] = in.nextInt();
            if (pointsY[yMaxI] < pointsY[i])
                yMaxI = i;
            yCount[pointsY[i] + OFFSET]++;
        }
        if (yCount[pointsY[yMaxI]] == 2) {
            out.println(-1);
            return 0;
        }

        double[][] dists = new double[n + 1][2 * n + 2];
        for (int i = 1; i < dists.length; i++)
            dists[i][2 * n + 1] = INF;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                double dist = Math.hypot(pointsX[i] - pointsX[j], pointsY[i] - pointsY[j]);
                if (pointsY[i] < pointsY[j])
                    dists[i + 1][j + 1] = dists[i + 1][j + n + 1] = dist;
                else
                    dists[i + 1][j + 1] = dists[i + 1][j + n + 1] = INF;
            }
        }
        dists[yMaxI + 1][2 * n + 1] = 0;

        int[] p = Utils.solveAssignmentProblem(dists);
        double ans = 0;
        for (int i = 1; i < p.length; i++)
            if (p[i] != 0)
                ans += dists[p[i]][i];
        if (ans >= INF)
            out.println(-1);
        else
            out.println(ans);

        /*
        int k = in.nextInt();

        HashMap<Integer, ArrayList<Event>>[] events = new HashMap[2];
        for (int i = 0; i < events.length; i++)
            events[i] = new HashMap<>();

        for (int i = 0; i < k; i++) {
            int xb = in.nextInt();
            int yb = in.nextInt();
            int xe = in.nextInt();
            int ye = in.nextInt();
            if (xb == xe) {
                if (events[0].get(xb) == null)
                    events[0].put(xb, new ArrayList<>());
                if (yb > ye) {
                    int tmp = yb;
                    yb = ye;
                    ye = tmp;
                }
                ArrayList<Event> curX = events[0].get(xb);
                curX.add(new Event(yb, 1));
                curX.add(new Event(ye, -1));
            } else {
                if (events[1].get(yb) == null)
                    events[1].put(yb, new ArrayList<>());
                if (xb > xe) {
                    int tmp = xb;
                    xb = xe;
                    xe = tmp;
                }
                ArrayList<Event> curY = events[1].get(yb);
                curY.add(new Event(xb, 1));
                curY.add(new Event(xe, -1));

            }
        }

        HashMap<Integer, Integer>[] batchSizes = new HashMap[2];
        for (int i = 0; i < batchSizes.length; i++)
            batchSizes[i] = new HashMap<>();

        for (int eventType = 0; eventType < events.length; eventType++) {
            HashMap<Integer, ArrayList<Event>> curMap = events[eventType];
            for (Map.Entry<Integer, ArrayList<Event>> kv : curMap.entrySet()) {
                ArrayList<Event> curEvents = kv.getValue();
                Collections.sort(curEvents);
                int totalLen = eventType == 0 ? m : n;
                int openedCount = 0;
                Event prev = null;
                for (int i = 0; i < curEvents.size(); i++) {
                    Event cur = curEvents.get(i);
                    if (openedCount != 0) {
                        totalLen -= (cur.pos - prev.pos);
                    }
                    openedCount += cur.delta;
                    prev = cur;
                }
                batchSizes[eventType].put(kv.getKey(), totalLen);
            }
        }

        ArrayList<Nim> nims = new ArrayList<>();
        nims.add(new Nim(-1, n - batchSizes[0].size() - 1, m, 0));
        nims.add(new Nim(-1, m - batchSizes[1].size() - 1, n, 1));
        for (int lineType = 0; lineType < batchSizes.length; lineType++) {
            for (Map.Entry<Integer, Integer> entry : batchSizes[lineType].entrySet())
                nims.add(new Nim(entry.getKey(), 1, entry.getValue(), lineType));
        }

        long grundy = 0;
        for (int i = 0; i < nims.size(); i++)
            grundy ^= nims.get(i).getGrungy();

        if (grundy == 0)
            out.print("SECOND");
        else {
            out.print("FIRST");
            for (int i = 0; i < nims.size(); i++)
        }
          */
        return 0;
    }


    FastScanner in;
    PrintWriter out;

    @Override
    public void run() {
        try {
            boolean ONLINE_JUDGE = false;
            try {
                Locale.setDefault(Locale.US);
                ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
            } catch (SecurityException e) {
                System.err.println("Operation forbidden");
            }


            long time = System.currentTimeMillis();
            if (ONLINE_JUDGE) {
                in = new FastScanner(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                in = new FastScanner(new FileReader("input.txt"));
                out = new PrintWriter("output.txt");
            }

            int ret = solve();
            out.close();
            in.close();

            long delta = System.currentTimeMillis() - time;

            long freeMem = Runtime.getRuntime().freeMemory();
            long totalMem = Runtime.getRuntime().totalMemory();

            System.err.printf("Time: %.3f s\n", delta / 1000.0f);
            System.err.printf("Memory: %.3f MB\n", (float)(totalMem - freeMem) / (1 << 20));

            if (ret != 0)
                System.exit(ret);

        } catch (Throwable t) {
            t.printStackTrace(System.err);
            System.exit(-1);
        }
    }
}

@SuppressWarnings("unused")
final class FastScanner {
    BufferedReader bufferedReader;
    StringTokenizer stringTokenizer;

    public FastScanner(Reader r) {
        bufferedReader = new BufferedReader(r);
    }

    public String nextToken() throws IOException, NullPointerException {
        while (stringTokenizer == null || !stringTokenizer.hasMoreTokens())
            stringTokenizer = new StringTokenizer(bufferedReader.readLine());
        return stringTokenizer.nextToken();
    }

    public String nextLine() throws IOException {
        return bufferedReader.readLine();
    }

    public int nextInt() throws IOException, NullPointerException {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    public BigInteger nextBigInteger() throws IOException {
        return new BigInteger(nextToken());
    }

    public float nextFloat() throws IOException {
        return Float.parseFloat(nextToken());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    public int read() throws IOException {
        return bufferedReader.read();
    }

    public void close() throws IOException {
        bufferedReader.close();
    }

    public int[] readIntArray(int n) throws Throwable {
        int[] array = new int[n];
        for (int i = 0; i < n; i++)
            array[i] = nextInt();
        return array;
    }

    @Override
    protected void finalize() throws Throwable {
        super.finalize();
        close();
    }
}

final class DisjointSetUnion {
    int[] parent;
    int[] rank;

    public DisjointSetUnion(int size) {
        parent = new int[size];
        rank = new int[size];
        for (int i = 0; i < size; i++)
            parent[i] = i;
    }

    public int getLeader(int element) {
        if (parent[element] == element)
            return element;
        else
            return parent[element] = getLeader(parent[element]);
    }

    public boolean union(int x, int y) {
        x = getLeader(x);
        y = getLeader(y);
        if (x == y)
            return true;
        if (rank[x] < rank[y]) {
            int temp = x;
            x = y;
            y = temp;
        }
        parent[y] = x;
        if (rank[x] == rank[y])
            ++rank[x];
        return false;
    }
}




@SuppressWarnings("unused")
final class Utils {
    private Utils() {}

    final static int INF_I = Integer.MAX_VALUE;
    final static double INF_D = Double.POSITIVE_INFINITY;
    final static long INF_L = Long.MAX_VALUE;


    public static int[] solveAssignmentProblem(double[][] a) {
        int n = a.length - 1;
        int m = a[0].length - 1;
        double[] u = new double[n + 1], v = new double[m + 1], minv = new double[m + 1];
        boolean[] used = new boolean[m + 1];
        int[] p = new int[m + 1], prev = new int[m + 1];
        for (int i = 1; i <= n; i++) {
            Arrays.fill(used, false);
            Arrays.fill(minv, INF_D);
            int j0 = 0;
            p[j0] = i;
            do {
                int i0 = p[j0];
                used[j0] = true;
                double delta = INF_D;
                int j1 = 0;
                for (int j = 1; j <= m; j++) {
                    if (!used[j]) {
                        double cur = a[i0][j] + u[i0] + v[j];
                        if (cur < minv[j]) {
                            minv[j] = cur;
                            prev[j] = j0;
                        }
                        if (minv[j] < delta) {
                            delta = minv[j];
                            j1 = j;
                        }
                    }
                }
                for (int j = 0; j <= m; j++) {
                    if (used[j]) {
                        u[p[j]] -= delta;
                        v[j]  += delta;
                    } else
                        minv[j] -= delta;
                }
                j0 = j1;
            } while (p[j0] != 0);
            do {
                int j1 = prev[j0];
                p[j0] = p[j1];
                j0 = j1;
            } while (j0 != 0);

        }
        return p;
    }


    //a - 1 indexed
    public static int[] hungarian(int[][] a) {
        int n = a.length - 1;
        int m = a[0].length - 1;
        int[] prev = new int[m + 1];
        int[] u = new int[n + 1];
        int[] v = new int[m + 1];
        boolean[] used = new boolean[m + 1];
        int[] p = new int[m + 1];
        int[] minv = new int[m + 1];
        for (int i = 1; i <= n; i++) {
            Arrays.fill(used, false);
            Arrays.fill(minv, INF_I);
            int j0 = 0;
            p[j0] = i;
            do {
                used[j0] = true;
                int i0 = p[j0];
                int delta = INF_I;
                int j1 = 0;
                for (int j = 1; j <= m; j++) {
                    if (!used[j]) {
                        int cur = a[i0][j] + u[i0] + v[j];
                        if (cur < minv[j]) {
                            minv[j] = cur;
                            prev[j] = j0;
                        }
                        if (minv[j] < delta) {
                            j1 = j;
                            delta = minv[j];
                        }
                    }
                }
                for (int j = 0; j <= m; j++) {
                    if (used[j]) {
                        u[p[j]] -= delta;
                        v[j] += delta;
                    } else
                        minv[j] -= delta;
                }
                j0 = j1;
            } while (p[j0] != 0);
            do {
                int j1 = prev[j0];
                p[j0] = p[j1];
                j0 = j1;
            } while (j0 != 0);
        }
        return p;
    }


    //a - 1 indexed


    public static int[] hungarian(long[][] a) {
        int n = a.length - 1;
        int m = a[0].length - 1;
        int[] prev = new int[m + 1];
        long[] u = new long[n + 1];
        long[] v = new long[m + 1];
        boolean[] used = new boolean[m + 1];
        int[] p = new int[m + 1];
        long[] minv = new long[m + 1];
        for (int i = 1; i <= n; i++) {
            Arrays.fill(used, false);
            Arrays.fill(minv, INF_L);
            int j0 = 0;
            p[j0] = i;
            do {
                used[j0] = true;
                int i0 = p[j0];
                long delta = INF_L;
                int j1 = 0;
                for (int j = 1; j <= m; j++) {
                    if (!used[j]) {
                        long cur = a[i0][j] + u[i0] + v[j];
                        if (cur < minv[j]) {
                            minv[j] = cur;
                            prev[j] = j0;
                        }
                        if (minv[j] < delta) {
                            j1 = j;
                            delta = minv[j];
                        }
                    }
                }
                for (int j = 0; j <= m; j++) {
                    if (used[j]) {
                        u[p[j]] -= delta;
                        v[j] += delta;
                    } else
                        minv[j] -= delta;
                }
                j0 = j1;
            } while (p[j0] != 0);
            do {
                int j1 = prev[j0];
                p[j0] = p[j1];
                j0 = j1;
            } while (j0 != 0);
        }
        return p;
    }

    public static long sqr(long x) {
        return x * x;
    }

    public static int gcd(int x, int y) {
        while (y > 0) {
            x %= y;
            int temp = x;
            x = y;
            y = temp;
        }
        return x;
    }

    public static int lcm(int x, int y) {
        return x / gcd(x, y) * y;
    }

    public static long gcd(long x, long y) {
        while (y > 0) {
            x %= y;
            long temp = x;
            x = y;
            y = temp;
        }
        return x;
    }

    public static long lcm(long x, long y) {
        return x / gcd(x, y) * y;
    }

    public static long modInverse(long x, long mod) {
        return BigInteger.valueOf(x).modInverse(BigInteger.valueOf(mod)).longValue();
    }

    static Random r = new Random(System.nanoTime());

    public static<T> void shuffle(T[] array) {
        int n = array.length;
        for (int i = 0; i < n; i++) {
            int j = r.nextInt(n);
            T t = array[i];
            array[i] = array[j];
            array[j] = t;
        }
    }

    public static void shuffle(int[] array) {
        int n = array.length;
        for (int i = 0; i < n; i++) {
            int j = r.nextInt(n);
            int t = array[i];
            array[i] = array[j];
            array[j] = t;
        }
    }
}