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:
// practice with rainboy
import java.io.*;
import java.util.*;

public class CF277E extends PrintWriter {
	CF277E() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		CF277E o = new CF277E(); o.main(); o.flush();
	}

	static final double INF = Double.MAX_VALUE;
	int[] next, hh; int $ = 1;
	int[] ii, jj, cc;
	double[] cost, cost_;
	int[] ao; double[] pi; int[] dd, ff;
	int[] pq, iq; int cnt;
	int n_, m_; double ans;
	void init(int n, int m) {
		next = new int[1 + m * 2]; hh = new int[1 + m * 2];
		ii = new int[m]; jj = new int[m]; cc = new int[m * 2];
		cost = new double[m]; cost_ = new double[m];
		ao = new int[n];
		pi = new double[n]; dd = new int[n]; ff = new int[n];
		pq = new int[1 + n]; iq = new int[n];
		n_ = n;
	}
	int link(int l, int h) {
		next[$] = l; hh[$] = h;
		return $++;
	}
	void link_(int i, int j, int c, double co) {
		int h = m_++;
		ii[h] = i; jj[h] = j;
		cc[h << 1] = c;
		cost[h] = co;
		ao[i] = link(ao[i], h << 1);
		ao[j] = link(ao[j], h << 1 | 1);
	}
	boolean less(int u, int v) {
		return pi[u] < pi[v] || pi[u] == pi[v] && dd[u] < dd[v];
	}
	int i2(int i) {
		return (i *= 2) > cnt ? 0 : i < cnt && less(pq[i + 1], pq[i]) ? i + 1 : i;
	}
	void pq_up(int u) {
		int i, j, v;
		for (i = iq[u]; (j = i / 2) > 0 && less(u, v = pq[j]); i = j)
			pq[iq[v] = i] = v;
		pq[iq[u] = i] = u;
	}
	void pq_dn(int u) {
		int i, j, v;
		for (i = iq[u]; (j = i2(i)) > 0 && less(v = pq[j], u); i = j)
			pq[iq[v] = i] = v;
		pq[iq[u] = i] = u;
	}
	void pq_add_last(int u) {
		pq[iq[u] = ++cnt] = u;
	}
	int pq_remove_first() {
		int u = pq[1], v = pq[cnt--];
		iq[v] = 1; pq_dn(v);
		return u;
	}
	boolean dijkstra(int s, int t) {
		Arrays.fill(pi, INF); pi[s] = 0;
		pq_add_last(s);
		while (cnt > 0) {
			int i = pq_remove_first();
			int d = dd[i] + 1;
			for (int l = ao[i]; l != 0; l = next[l]) {
				int h_ = hh[l];
				if (cc[h_] > 0) {
					int h = h_ >> 1, j = i ^ ii[h] ^ jj[h];
					double p = pi[i] + ((h_ & 1) == 0 ? cost_[h] : -cost_[h]);
					if (pi[j] > p || pi[j] == p && dd[j] > d) {
						if (pi[j] == INF)
							pq_add_last(j);
						pi[j] = p;
						dd[j] = d;
						ff[j] = h_;
						pq_up(j);
					}
				}
			}
		}
		return pi[t] != INF;
	}
	int trace(int s, int t) {
		while (t != s) {
			int h_ = ff[t], h = h_ >> 1;
			cc[h_]--; cc[h_ ^ 1]++;
			t ^= ii[h] ^ jj[h];
		}
		return 1;
	}
	int edmonds_karp(int s, int t) {
		for (int h = 0; h < m_; h++)
			cost_[h] = cost[h];
		int f = 0;
		while (dijkstra(s, t)) {
			f += trace(s, t);
			for (int h = 0; h < m_; h++) {
				int i = ii[h], j = jj[h];
				if (pi[i] != INF && pi[j] != INF) {
					// pi[j] <= pi[i] + cost_[h]
					// cost_[h] + pi[i] - pi[j] >= 0
					cost_[h] += pi[i] - pi[j];
				}
			}
		}
		for (int h = 0; h < m_; h++)
			ans += cc[h << 1 | 1] * cost[h];
		return f;
	}
	void main() {
		int n = sc.nextInt();
		int[] xx = new int[n];
		int[] yy = new int[n];
		for (int i = 0; i < n; i++) {
			xx[i] = sc.nextInt();
			yy[i] = sc.nextInt();
		}
		init(1 + n + n + 1, n + n * (n - 1) / 2 + n);
		int s = n * 2, t = s + 1;
		for (int i = 0; i < n; i++)
			link_(s, i, 1, 0);
		for (int i = 0; i < n; i++)
			for (int j = i + 1; j < n; j++)
				if (yy[i] != yy[j]) {
					double d = Math.hypot(xx[j] - xx[i], yy[j] - yy[i]);
					if (yy[i] < yy[j])
						link_(i, n + j, n, d);
					else
						link_(j, n + i, n, d);
				}
		for (int i = 0; i < n; i++)
			link_(n + i, t, 2, 0);
		if (edmonds_karp(s, t) == n - 1)
			println(ans);
		else
			println(-1);
	}
}