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 from, to, cap, flow;
  double d;
  int p;
} e[405 * 405];
int cou, h[405 * 2];
int s, t, pre[405 * 2], pos[405 * 2];
bool inq[405 * 2];
double dis[405 * 2];
pair<double, double> p[405];
void Addedge(int from, int to, int cap, double dis) {
  cou++;
  e[cou].from = from;
  e[cou].to = to, e[cou].cap = cap, e[cou].flow = 0, e[cou].d = dis,
  e[cou].p = h[from];
  h[from] = cou;
  cou++;
  e[cou].from = to;
  e[cou].to = from, e[cou].cap = 0, e[cou].flow = 0, e[cou].d = -dis,
  e[cou].p = h[to];
  h[to] = cou;
}
inline double get_dis(double x_1, double y_1, double x_2, double y_2) {
  return sqrt((x_1 - x_2) * (x_1 - x_2) + (y_1 - y_2) * (y_1 - y_2));
}
bool SPFA() {
  queue<int> q;
  int i, x, v;
  memset(pre, -1, sizeof(pre));
  memset(inq, 0, sizeof(inq));
  for (i = s + 1; i <= t; i++) dis[i] = 1000000000;
  dis[s] = 0;
  q.push(s);
  while (!q.empty()) {
    x = q.front();
    q.pop();
    inq[x] = 0;
    for (i = h[x]; i; i = e[i].p) {
      Edge &te = e[i];
      v = te.to;
      if (te.cap > te.flow && dis[v] > dis[x] + te.d) {
        dis[v] = dis[x] + te.d;
        pre[v] = x;
        pos[v] = i;
        if (!inq[v]) q.push(v), inq[v] = 1;
      }
    }
  }
  return pre[t] == -1 ? 0 : 1;
}
void MCMF(int &flow, double &cost) {
  flow = cost = 0;
  int i, f;
  while (SPFA()) {
    f = 1000000000;
    for (i = t; i != s; i = pre[i]) f = min(f, e[pos[i]].cap - e[pos[i]].flow);
    flow += f;
    cost += f * dis[t];
    for (i = t; i != s; i = pre[i]) {
      e[pos[i]].flow += f;
      e[((pos[i] - 1) ^ 1) + 1].flow -= f;
    }
  }
}
int main() {
  int n, i, j;
  cin >> n;
  for (i = 1; i <= n; i++) scanf("%lf%lf", &p[i].second, &p[i].first);
  sort(p + 1, p + 1 + n);
  reverse(p + 1, p + 1 + n);
  s = 0, t = n * 2 + 1;
  for (i = 1; i <= n; i++) {
    Addedge(s, i, 2, 0);
    for (j = i + 1; j <= n; j++)
      if (p[i].first > p[j].first) {
        Addedge(i, j + n, 1,
                get_dis(p[i].first, p[i].second, p[j].first, p[j].second));
      }
  }
  for (i = 2; i <= n; i++) Addedge(i + n, t, 1, 0);
  int flow;
  double cost;
  MCMF(flow, cost);
  if (flow != n - 1)
    printf("-1\n");
  else
    printf("%.8f\n", cost);
  return 0;
}