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 v, c;
  double d;
  Edge *next, *rev;
} * E[1005], *Path[1005], EE[1005 * 1005];
int ECnt = 0;
int X[1005], Y[1005];
queue<int> Q;
double Dis[1005];
bool Inq[1005];
int Cnt[1005], Low[1005];
int MaxFlow = 0;
double MinCost = 0.0;
double CalDis(int x1, int y1, int x2, int y2) {
  return sqrt(pow(x1 - x2 - 0.0, 2) + pow(y1 - y2 - 0.0, 2));
}
void AddEdge(int i, int j, int c, double d) {
  EE[ECnt].v = j, EE[ECnt].c = c, EE[ECnt].d = d, EE[ECnt].next = E[i],
  EE[ECnt].rev = &EE[ECnt + 1];
  E[i] = &EE[ECnt];
  ECnt++;
  EE[ECnt].v = i, EE[ECnt].c = 0, EE[ECnt].d = -d, EE[ECnt].next = E[j],
  EE[ECnt].rev = &EE[ECnt - 1];
  E[j] = &EE[ECnt];
  ECnt++;
}
void BuildGraph(int n) {
  int i, j, u, v;
  double d;
  for (i = 1; i <= n; ++i) {
    AddEdge(0, i, 2, 0.0);
    AddEdge(i + n, 2 * n + 1, 1, 0.0);
    for (j = 1; j <= n; ++j) {
      if (Y[i] > Y[j]) {
        d = CalDis(X[i], Y[i], X[j], Y[j]);
        AddEdge(i, j + n, 1, d);
      }
    }
  }
}
bool SPFA(int s, int t) {
  while (!Q.empty()) Q.pop();
  int i, u, v, c;
  double d;
  Edge *tp;
  for (i = 0; i <= t; ++i) {
    Dis[i] = 1e9;
    Inq[i] = false;
    Cnt[i] = 0;
  }
  Q.push(s);
  Dis[s] = 0.0, Inq[s] = true, Cnt[s] = 1, Path[s] = NULL, Low[s] = 0x7fffffff;
  while (!Q.empty()) {
    u = Q.front();
    Inq[u] = false, Q.pop();
    for (tp = E[u]; tp; tp = tp->next) {
      v = tp->v, c = tp->c, d = tp->d;
      if (c && Dis[v] > Dis[u] + d + 1e-9) {
        Dis[v] = Dis[u] + d;
        Path[v] = tp;
        Low[v] = min(Low[u], c);
        if (!Inq[v]) {
          Cnt[v]++;
          if (Cnt[v] > t + 1) return 0;
          Q.push(v);
          Inq[v] = true;
        }
      }
    }
  }
  return Dis[t] < 1e9;
}
void MaxFlowMinCost(int s, int t) {
  MaxFlow = 0, MinCost = 0.0;
  int i, u, v;
  while (SPFA(s, t)) {
    MaxFlow += Low[t];
    MinCost += Dis[t] * Low[t];
    for (v = t; v != s; v = u) {
      u = Path[v]->rev->v;
      Path[v]->c -= Low[t];
      Path[v]->rev->c += Low[t];
    }
  }
}
int main() {
  int n, i;
  cin >> n;
  for (i = 1; i <= n; ++i) cin >> X[i] >> Y[i];
  BuildGraph(n);
  MaxFlowMinCost(0, 2 * n + 1);
  if (MaxFlow == n - 1) {
    cout.precision(10);
    cout << MinCost << endl;
  } else
    cout << -1 << endl;
  return 0;
}