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 double EPS = 1e-9;
const double oo = 1e9;
template <class Flow, class Cost>
struct MinCostFlow {
  struct Edge {
    int v, inv;
    Flow c, f;
    Cost w;
    Edge(){};
    Edge(int v, Flow c, Cost w, int inv) : v(v), inv(inv), c(c), f(0), w(w) {}
  };
  int n, s, t;
  vector<vector<Edge> > e;
  vector<Cost> d;
  vector<int> parent, pEdge, state;
  deque<int> q;
  MinCostFlow(int n, int s = 1, int t = 2)
      : n(n),
        s(s),
        t(t),
        e(n + 1),
        d(n + 1),
        parent(n + 1),
        pEdge(n + 1),
        state(n + 1) {}
  void addEdge(int u, int v, Flow c, Cost w) {
    int i = e[u].size(), j = e[v].size();
    e[u].push_back(Edge(v, c, w, j));
    e[v].push_back(Edge(u, 0, -w, i));
  }
  bool findPath() {
    for (int i = 1; i <= n; ++i) {
      d[i] = oo;
      state[i] = 0;
      parent[i] = pEdge[i] = -1;
    }
    d[s] = 0;
    while (!q.empty()) q.pop_front();
    q.push_front(s);
    while (!q.empty()) {
      int u = q.front();
      q.pop_front();
      state[u] = 2;
      for (int i = 0, sz = (int)e[u].size(); i < sz; ++i)
        if (e[u][i].f < e[u][i].c) {
          int v = e[u][i].v;
          Cost tmp = d[u] + e[u][i].w;
          if (tmp + EPS < d[v]) {
            d[v] = tmp;
            parent[v] = u;
            pEdge[v] = i;
            if (state[v] == 0)
              q.push_back(v);
            else if (state[v] == 2)
              q.push_front(v);
            state[v] = 1;
          }
        }
    }
    return (parent[t] > -1);
  }
  pair<Flow, Cost> getFlow(Flow flowLimit = oo) {
    Flow flow = 0;
    Cost cost = 0;
    while (findPath()) {
      Flow add = flowLimit - flow;
      if (add <= 0) break;
      for (int v = t; v != s; v = parent[v]) {
        int u = parent[v], i = pEdge[v];
        add = min(add, e[u][i].c - e[u][i].f);
      }
      for (int v = t; v != s; v = parent[v]) {
        int u = parent[v], i = pEdge[v];
        e[u][i].f += add;
        e[v][e[u][i].inv].f -= add;
        cost += Cost(add) * e[u][i].w;
      }
      flow += add;
    }
    return make_pair(flow, cost);
  }
};
int x[404], y[404];
double dis(int i, int j) {
  double res = (x[i] - x[j]) * (x[i] - x[j]);
  res += (y[i] - y[j]) * (y[i] - y[j]);
  return sqrt(res);
}
int main() {
  int n;
  scanf("%d", &n);
  MinCostFlow<int, double> mcmf(2 * n + 5, 1, 2 * n + 2);
  for (int i = 1; i <= n; ++i) {
    scanf("%d %d", x + i, y + i);
  }
  for (int i = 1; i <= n; ++i) {
    mcmf.addEdge(1, i + 1, 1, 0);
    mcmf.addEdge(i + n + 1, 2 * n + 2, 2, 0);
    for (int j = 1; j <= n; ++j) {
      if (y[j] < y[i]) {
        mcmf.addEdge(j + 1, i + n + 1, 1, dis(i, j));
      }
    }
  }
  auto res = mcmf.getFlow();
  if (res.first != n - 1) {
    printf("-1");
  } else {
    printf("%0.6lf", res.second);
  }
  return 0;
}