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>
const double inf = 1000000009;
using namespace std;
struct node {
  int to, next, flow;
  double val;
} p[320005];
int tot, n, m, head[1005], S, T, last[1005], from[1005], c[10005], q[10005],
    res;
bool vis[1005];
double ans[1005];
int x[405], y[405];
inline void add(int x, int y, int f, double v) {
  p[tot].to = y;
  p[tot].next = head[x];
  p[tot].flow = f;
  p[tot].val = v;
  head[x] = tot++;
  p[tot].to = x;
  p[tot].next = head[y];
  p[tot].flow = 0;
  p[tot].val = -v;
  head[y] = tot++;
}
inline bool spfa(int x) {
  queue<int> q;
  q.push(x);
  memset(vis, 0, sizeof(vis));
  for (int i = 0; i <= T; i++) ans[i] = inf;
  from[x] = -1;
  last[x] = -1;
  ans[x] = 0.0;
  vis[x] = 1;
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    vis[x] = 0;
    for (int i = head[x]; ~i; i = p[i].next) {
      int y = p[i].to, f = p[i].flow;
      double v = p[i].val;
      if (!f) continue;
      if (ans[x] + v < ans[y]) {
        ans[y] = v + ans[x];
        if (!vis[y]) vis[y] = true, q.push(y);
        from[y] = x;
        last[y] = i;
      }
    }
  }
  return ans[T] < inf;
}
inline double dis(int a, int b) {
  return sqrt((double)(((double)(x[a] - x[b])) * ((double)(x[a] - x[b])) +
                       ((double)(y[a] - y[b])) * ((double)(y[a] - y[b]))));
}
inline void print(int x) {
  if (x == -1) return;
  print(from[x]);
  c[++res] = x;
  q[res] = last[x];
}
int main() {
  memset(head, -1, sizeof(head));
  scanf("%d", &n);
  S = 0, T = n * 2 + 1;
  for (int i = 1; i <= n; i++)
    add(S, i, 2, 0), add(i + n, T, 1, 0), scanf("%d%d", &x[i], &y[i]);
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      if (y[i] > y[j])
        add(i, j + n, 1, dis(i, j));
      else if (y[j] > y[i])
        add(j, i + n, 1, dis(i, j));
  int ans1;
  double ans2;
  ans1 = 0;
  ans2 = 0.0;
  while (spfa(S)) {
    res = 0;
    print(T);
    int minx = inf;
    for (int i = 2; i <= res; i++) minx = min(minx, p[q[i]].flow);
    for (int i = 2; i <= res; i++) {
      int g = q[i];
      p[g].flow -= minx;
      p[g ^ 1].flow += minx;
      ans2 += minx * p[g].val;
    }
    ans1 += minx;
  }
  if (ans1 < n - 1)
    puts("-1");
  else
    printf("%.12f\n", ans2);
  return 0;
}