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;
struct edge {
  int d, f, n;
  double c;
} b[640005];
int x[405], y[405], w[405], a[1000], n, i, s, p, sss, ed = 1, S, T, j, q[1000],
                                                      st, pre[1000], go[1000];
double d[1000], ans;
bool v[1000];
template <class T>
void up(T& a, T b) {
  if (a < b) a = b;
}
template <class T>
void down(T& a, T b) {
  if (a > b) a = b;
}
int comp(const void* a, const void* b) {
  return y[*(int*)b] - y[*(int*)a] ? y[*(int*)b] - y[*(int*)a]
                                   : x[*(int*)a] - x[*(int*)b];
}
double sqr(double x) { return x * x; }
double dis(int x1, int y1, int x2, int y2) {
  return sqrt(sqr(x1 - x2) + sqr(y1 - y2));
}
void link(int s, int t, int f, double c) {
  b[++ed] = (edge){t, f, a[s], c};
  a[s] = ed;
  b[++ed] = (edge){s, 0, a[t], -c};
  a[t] = ed;
}
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d%d", &x[i], &y[i]), w[i] = i;
  qsort(w + 1, n, sizeof(int), comp);
  S = n * 2 + 1, T = n * 2 + 2;
  for (i = 2; i <= n; i++)
    for (link(S, w[i], 1, 0), link(w[i] + n, T, 2, 0), j = 1; y[w[i]] < y[w[j]];
         j++)
      link(w[i], w[j] + n, 1, dis(x[w[i]], y[w[i]], x[w[j]], y[w[j]]));
  link(w[1] + n, T, 2, 0);
  for (sss = 2; sss <= n; sss++) {
    memset(d, 100, sizeof(d));
    q[S] = 0;
    d[S] = 0;
    for (st = ed = S; st; v[st] = 0, st = q[st])
      for (i = a[st]; i; i = b[i].n)
        if (b[i].f && b[i].c + d[st] < d[b[i].d] - 1e-9) {
          d[b[i].d] = b[i].c + d[st];
          pre[b[i].d] = st;
          go[b[i].d] = i;
          if (!v[b[i].d])
            if (st == ed || d[q[st]] < d[b[i].d])
              q[ed] = b[i].d, q[ed = b[i].d] = 0;
            else
              q[b[i].d] = q[st], q[st] = b[i].d;
          v[b[i].d] = 1;
        }
    if (d[T] > 1e10)
      break;
    else
      ans += d[T];
    for (i = T; i != S; i = pre[i]) b[go[i]].f -= 1, b[go[i] ^ 1].f += 1;
  }
  if (sss <= n)
    puts("-1");
  else
    printf("%.7f", ans);
  return 0;
}