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[805], S, T, last[805], from[805], c[805], ed[805], res;
bool vis[805];
double ans[805];
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++;
}
struct queueue {
  int a[805], head, tail;
  inline void pre() {
    memset(a, 0, sizeof(a));
    head = 0;
    tail = 0;
  }
  inline void push(int x) {
    a[tail] = x;
    tail++;
    if (tail == 802) tail = 0;
  }
  inline int front() { return a[head]; }
  inline void pop() {
    head++;
    if (head == 802) head = 0;
  }
  inline bool empty() { return head == tail; }
} q;
bool spfa(int x) {
  q.pre();
  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) {
      if (!p[i].flow) continue;
      int y = p[i].to;
      double v = ans[x] + p[i].val;
      if (v < ans[y]) {
        ans[y] = v;
        if (!vis[y]) vis[y] = 1, 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) print(from[x]), c[++res] = x, ed[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);
    for (int i = 2; i <= res; i++) {
      int g = ed[i];
      p[g].flow--;
      p[g ^ 1].flow++;
      ans2 += p[g].val;
    }
    ans1++;
  }
  if (ans1 < n - 1)
    puts("-1");
  else
    printf("%.12f\n", ans2);
  return 0;
}