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;
const int MAXN = 501;
int n;
int x[MAXN], y[MAXN];
namespace nflow {
const int INFINITE = 0x7FFFFFFF;
const int MAXV = 1001;
const int MAXE = 200001;
typedef int vtx[MAXV];
typedef int edg[MAXE];
int n, s, t, w;
vtx lk, ds;
edg nx, tl, cp;
queue<int> q;
inline void addEdge(int u, int v, int c) {
  if (!w) w++;
  w++, nx[w] = lk[u], lk[u] = w, tl[w] = v, cp[w] = c;
  w++, nx[w] = lk[v], lk[v] = w, tl[w] = u, cp[w] = 0;
}
inline bool BFS() {
  for (int i = 1; i <= n; ++i) ds[i] = 0;
  ds[s] = 1, q.push(s);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int e = lk[u]; e > 0; e = nx[e]) {
      int v = tl[e];
      if (cp[e] > 0 && !ds[v]) {
        ds[v] = ds[u] + 1;
        q.push(v);
      }
    }
  }
  return ds[t];
}
inline int DFS(int u, int curMin) {
  if (u == t) return curMin;
  int maxFlow = 0;
  for (int e = lk[u]; e > 0; e = nx[e]) {
    int v = tl[e];
    if (cp[e] > 0 && ds[v] == ds[u] + 1) {
      int flow = DFS(v, min(curMin, cp[e]));
      cp[e] -= flow, curMin -= flow;
      cp[e ^ 1] += flow, maxFlow += flow;
    }
  }
  return maxFlow;
}
inline int solve() {
  int res = 0, flow = 0;
  while (BFS())
    while (flow = DFS(s, INFINITE)) res += flow;
  return res;
}
}  // namespace nflow
namespace cflow {
const int INFINITE = 0x7FFFFFFF;
const int MAXV = 1001;
const int MAXE = 200001;
typedef int vtx[MAXV];
typedef int edg[MAXE];
int n, s, t, w;
double ds[MAXV], wt[MAXE];
vtx lk, ex, pr;
edg nx, tl, cp;
queue<int> q;
inline void addEdge(int u, int v, int c, double f) {
  if (!w) w++;
  w++, nx[w] = lk[u], lk[u] = w, tl[w] = v, cp[w] = c, wt[w] = f;
  w++, nx[w] = lk[v], lk[v] = w, tl[w] = u, cp[w] = 0, wt[w] = -f;
}
inline bool SPFA() {
  for (int i = 1; i <= n; ++i) ds[i] = INFINITE, ex[i] = false;
  ds[s] = 0, q.push(s);
  ex[s] = true;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    ex[u] = false;
    for (int e = lk[u]; e > 0; e = nx[e]) {
      int v = tl[e];
      if (cp[e] > 0 && ds[v] > ds[u] + wt[e]) {
        ds[v] = ds[u] + wt[e];
        pr[v] = e;
        if (!ex[v]) ex[v] = true, q.push(v);
      }
    }
  }
  return ds[t] < INFINITE;
}
inline double fordFulkerson() {
  int flow = INFINITE;
  double res = 0;
  for (int u = t; u != s; u = tl[pr[u] ^ 1]) flow = min(flow, cp[pr[u]]);
  for (int u = t; u != s; u = tl[pr[u] ^ 1]) {
    int e = pr[u];
    cp[e] -= flow, cp[e ^ 1] += flow;
    res += flow * wt[e];
  }
  return res;
}
inline double solve() {
  double res = 0;
  while (SPFA()) res += fordFulkerson();
  return res;
}
}  // namespace cflow
int s, t, idA[MAXN], idB[MAXN];
inline void assign() {
  s = ++t;
  for (int i = 1; i <= n; ++i) idA[i] = ++t;
  for (int i = 1; i <= n; ++i) idB[i] = ++t;
  t = ++t;
}
int main() {
  scanf("%d\n", &n);
  for (int i = 1; i <= n; ++i) scanf("%d %d\n", &x[i], &y[i]);
  assign();
  for (int i = 1; i <= n; ++i) nflow::addEdge(s, idA[i], 2);
  for (int i = 1; i <= n; ++i) nflow::addEdge(idB[i], t, 1);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      if (i != j && y[i] > y[j]) nflow::addEdge(idA[i], idB[j], 1);
  nflow::s = s, nflow::n = nflow::t = t;
  if (nflow::solve() < n - 1)
    printf("-1\n");
  else {
    for (int i = 1; i <= n; ++i) cflow::addEdge(s, idA[i], 2, 0);
    for (int i = 1; i <= n; ++i) cflow::addEdge(idB[i], t, 1, 0);
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j)
        if (i != j && y[i] > y[j])
          cflow::addEdge(idA[i], idB[j], 1,
                         (double)(sqrt(((x[i] - x[j]) * (x[i] - x[j])) +
                                       ((y[i] - y[j]) * (y[i] - y[j])))));
    cflow::s = s, cflow::n = cflow::t = t;
    double res = cflow::solve();
    printf("%.15f\n", res);
  }
  fclose(stdin);
  fclose(stdout);
  return 0;
}