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 = 4e2 + 5;
const int inf = 0x3f3f3f3f;
const long long linf = 0x3f3f3f3f3f3f3f3f;
template <const int MAXN, const int MAXM>
struct MCMF {
  struct Edge {
    int next, to, flow;
    long double w;
  } e[MAXM << 1];
  int head[MAXN], etot;
  inline void add_one(int u, int v, int flow, long double w) {
    e[++etot] = (Edge){head[u], v, flow, w};
    head[u] = etot;
  }
  inline void add_edge(int u, int v, int flow, long double w) {
    add_one(u, v, flow, w);
    add_one(v, u, 0, -w);
  }
  int n, s, t, flow[MAXN], pre[MAXN];
  long double dis[MAXN];
  inline void clear(void) {
    etot = -1;
    memset(head, -1, sizeof(head));
  }
  inline void init(int _n, int _s, int _t) {
    n = _n;
    s = _s;
    t = _t;
  }
  bool spfa(void) {
    for (int i = 1; i <= n; ++i) dis[i] = linf;
    static bool vis[MAXN];
    queue<int> q;
    flow[s] = inf;
    dis[s] = 0;
    q.push(s);
    vis[s] = 1;
    while (q.size()) {
      int u = q.front();
      q.pop();
      vis[u] = 0;
      for (int i = head[u]; ~i; i = e[i].next)
        if (e[i].flow) {
          int v = e[i].to;
          if (dis[v] > dis[u] + e[i].w) {
            dis[v] = dis[u] + e[i].w;
            pre[v] = i;
            flow[v] = min(flow[u], e[i].flow);
            if (!vis[v]) q.push(v), vis[v] = 1;
          }
        }
    }
    return dis[t] < linf;
  }
  pair<int, long double> solve(void) {
    int resf = 0;
    long double resc = 0;
    while (spfa()) {
      resf += flow[t];
      resc += flow[t] * dis[t];
      int u = t;
      while (u != s)
        e[pre[u]].flow -= flow[t], e[pre[u] ^ 1].flow += flow[t],
            u = e[pre[u] ^ 1].to;
    }
    return make_pair(resf, resc);
  }
};
inline long double dist(pair<int, int> p, pair<int, int> q) {
  return sqrtl((p.first - q.first) * (p.first - q.first) +
               (p.second - q.second) * (p.second - q.second));
}
pair<int, int> p[MAXN];
int main(void) {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d%d", &p[i].first, &p[i].second);
  static MCMF<MAXN * 2, MAXN * MAXN> mcmf;
  mcmf.clear();
  int s = 1, t = (n << 1) + 2;
  mcmf.init(t, s, t);
  for (int i = 1; i <= n; ++i) {
    mcmf.add_edge(i << 1, t, 1, 0);
    mcmf.add_edge(s, i << 1 | 1, 2, 0);
    for (int j = 1; j <= n; ++j)
      if (p[j].second < p[i].second)
        mcmf.add_edge(i << 1 | 1, j << 1, 1, dist(p[i], p[j]));
  }
  pair<int, long double> res = mcmf.solve();
  if (res.first != n - 1)
    printf("-1");
  else
    printf("%.20lf", (double)res.second);
  return 0;
}