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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 850;
const int MAXM = 335000;
const double EPS = 1e-8;
const double C_INF = 1e9;
const int F_INF = 1e9;
int fst[MAXN], nxt[MAXM], to[MAXM];
int cap[MAXM];
double cost[MAXM];
int V, E;
inline void init(int n = MAXN) {
  memset(fst, -1, sizeof(int) * n);
  V = E = 0;
}
inline int add_node() {
  V++;
  return V - 1;
}
inline void add_edge(int u, int v, int f, double w) {
  to[E] = v, cap[E] = f, cost[E] = w, nxt[E] = fst[u], fst[u] = E++;
  to[E] = u, cap[E] = 0, cost[E] = -w, nxt[E] = fst[v], fst[v] = E++;
}
int prv[MAXN], q[MAXN], chk[MAXN];
double dis[MAXN];
void SSSP(int S, int T, int n) {
  int h = 0, t = 0;
  for (int j = 0; j < n; j++) dis[j] = C_INF;
  memset(prv, -1, sizeof(int) * n);
  dis[S] = 0, q[t++] = S, chk[S] = 1;
  while (h != t) {
    int u = q[h++];
    chk[u] = 0;
    if (h == MAXN) h = 0;
    for (int j = fst[u]; ~j; j = nxt[j])
      if (cap[j]) {
        int v = to[j];
        if (dis[v] > dis[u] + cost[j] + EPS) {
          dis[v] = dis[u] + cost[j], prv[v] = j;
          if (!chk[v]) {
            q[t++] = v;
            chk[v] = 1;
            if (t == MAXN) t = 0;
          }
        }
      }
  }
}
double ans;
double solve(int S, int T, int n = V) {
  double ret = 0;
  while (1) {
    SSSP(S, T, n);
    if (!~prv[T]) break;
    int flw = F_INF;
    for (int u = T; u != S; u = to[prv[u] ^ 1]) flw = min(flw, cap[prv[u]]);
    ret += dis[T] * flw;
    ans += flw;
    for (int u = T; u != S; u = to[prv[u] ^ 1])
      cap[prv[u]] -= flw, cap[prv[u] ^ 1] += flw;
  }
  return ret;
}
double dist(pair<int, int> x, pair<int, int> y) {
  double tp = (x.first - y.first) * (x.first - y.first) +
              (x.second - y.second) * (x.second - y.second);
  return sqrt(tp);
}
pair<int, int> a[405];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i].second >> a[i].first;
  sort(a, a + n);
  int S = 0, T = 2 * n + 1;
  init();
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      if (a[i].first == a[j].first) continue;
      add_edge(2 * i + 2, j * 2 + 1, 1, dist(a[i], a[j]));
    }
    add_edge(S, 2 * i + 2, 1, 0);
    add_edge(2 * i + 1, T, 2, 0);
  }
  add_edge(2 * (n - 1) + 1, T, 2, 0);
  double ret = solve(S, T, 2 * n + 3);
  cout << fixed << setprecision(8);
  if (ans == n - 1)
    cout << ret << '\n';
  else
    cout << -1 << '\n';
  return 0;
}