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;
int n, qd[400005], qn[400005], qc[400005], l[2005], E;
double D[2005], cost, qw[400005];
int flow, q[2005], u[2005], par[2005], f[2005];
int S, T, V, x[2005], y[2005], P;
void bd(int x, int y, int cap, double w) {
  qd[++E] = y;
  qn[E] = l[x];
  qc[E] = cap;
  qw[E] = w;
  l[x] = E;
}
int Min_Cost_Flow() {
  for (int i = (0); i < (V); i++) {
    D[i] = (1e20) * 1.2;
    u[i] = 0;
  }
  D[S] = 0.0;
  q[0] = S;
  int siz = 1;
  for (int i = 0; siz; i++) {
    siz--;
    if (i == V) i = 0;
    u[q[i]] = 0;
    for (int k = l[q[i]]; k != -1; k = qn[k]) {
      if (qc[k] <= 0) continue;
      if (D[q[i]] + qw[k] < D[qd[k]]) {
        D[qd[k]] = D[q[i]] + qw[k];
        par[qd[k]] = q[i];
        f[qd[k]] = k;
        if (!u[qd[k]]) {
          ++siz;
          int t = i + siz;
          if (t >= V) t = t - V;
          q[t] = qd[k];
          u[qd[k]] = 1;
        }
      }
    }
  }
  if (D[T] > (1e20))
    return 0;
  else {
    cost += D[T];
    int cur = T;
    while (cur != S) {
      qc[f[cur]]--;
      if (f[cur] & 1)
        qc[f[cur] + 1]++;
      else
        qc[f[cur] - 1]++;
      cur = par[cur];
    }
    return 1;
  }
}
double dis(int a, int b) {
  return sqrt((x[a] - x[b]) * 1.0 * (x[a] - x[b]) +
              (y[a] - y[b]) * 1.0 * (y[a] - y[b]));
}
int main() {
  scanf("%d", &n);
  for (int i = (0); i < (n); i++) scanf("%d%d", &x[i], &y[i]);
  memset(l, -1, sizeof(l));
  E = 0;
  P = n;
  S = 2 * n;
  T = 2 * n + 1;
  V = 2 * n + 2;
  for (int i = (0); i < (n); i++)
    for (int j = (0); j < (n); j++)
      if (y[i] > y[j]) {
        bd(i, j + P, 1, dis(i, j));
        bd(j + P, i, 0, -dis(i, j));
      }
  for (int i = (0); i < (n); i++) {
    bd(S, i, 2, 0);
    bd(i, S, 0, 0);
    bd(i + P, T, 1, 0);
    bd(T, i + P, 0, 0);
  }
  cost = 0.0;
  flow = 0;
  while (Min_Cost_Flow()) flow++;
  if (flow == n - 1)
    printf("%.9f\n", cost);
  else
    printf("-1\n");
  return 0;
}