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 N = 410, V = 500010;
int n;
int x[N], y[N];
template <typename flow_t = int, typename cost_t = int>
struct MinCostMaxFlow {
  const flow_t FLOW_INF = numeric_limits<flow_t>::max() / 2;
  const cost_t COST_INF = numeric_limits<cost_t>::max() / 2;
  int n, s, t;
  vector<vector<int>> adj;
  vector<int> to;
  vector<flow_t> f, c;
  vector<cost_t> cost;
  vector<cost_t> pot;
  vector<cost_t> d;
  vector<int> prev;
  vector<bool> used;
  MinCostMaxFlow(int n, int s, int t)
      : n(n),
        s(s),
        t(t),
        adj(n, vector<int>()),
        d(n, -1),
        prev(n, -1),
        pot(n, 0),
        used(n, 0) {}
  int addEdge(int u, int v, flow_t _c, cost_t _cost) {
    adj[u].push_back(to.size());
    to.push_back(v);
    f.push_back(0);
    c.push_back(_c);
    cost.push_back(_cost);
    adj[v].push_back(to.size());
    to.push_back(u);
    f.push_back(0);
    c.push_back(0);
    cost.push_back(-_cost);
    return (int)to.size() - 2;
  }
  bool dijkstra() {
    fill(prev.begin(), prev.end(), -1);
    fill(d.begin(), d.end(), COST_INF);
    fill(used.begin(), used.end(), 0);
    d[s] = 0;
    priority_queue<pair<int, int>, vector<pair<int, int>>,
                   greater<pair<int, int>>>
        ss;
    ss.push({0, s});
    while (!ss.empty()) {
      int u = ss.top().second;
      ss.pop();
      if (used[u]) continue;
      used[u] = 1;
      for (int id : adj[u]) {
        int v = to[id];
        cost_t now = d[u] + pot[u] - pot[v] + cost[id];
        if (!used[v] && d[v] > now && f[id] < c[id]) {
          d[v] = now;
          prev[v] = id;
          ss.push({d[v], v});
        }
      }
    }
    for (int i = 0; i < n; i++) pot[i] += d[i];
    return prev[t] != -1;
  }
  pair<flow_t, cost_t> maxFlow() {
    flow_t res = 0;
    cost_t minCost = 0;
    while (dijkstra()) {
      int x = t;
      flow_t now = FLOW_INF;
      while (x != s) {
        int id = prev[x];
        now = min(now, c[id] - f[id]);
        x = to[id ^ 1];
      }
      x = t;
      while (x != s) {
        int id = prev[x];
        minCost += cost[id] * now;
        f[id] += now;
        f[id ^ 1] -= now;
        x = to[id ^ 1];
      }
      res += now;
    }
    return {res, minCost};
  }
  void init() {
    fill(pot.begin(), pot.end(), COST_INF);
    pot[s] = 0;
    bool changed = 1;
    while (changed) {
      changed = 0;
      for (int i = 0; i < n; i++)
        if (pot[i] < COST_INF) {
          for (int id : adj[i]) {
            int v = to[id];
            if (pot[v] > pot[i] + cost[id] && f[id] < c[id]) {
              pot[v] = pot[i] + cost[id];
              changed = 1;
            }
          }
        }
    }
  }
};
long double dis(int u, int v) {
  return sqrt((x[u] - x[v]) * (x[u] - x[v]) + (y[u] - y[v]) * (y[u] - y[v]));
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", x + i, y + i);
  }
  MinCostMaxFlow<int, long double> f(n * 2 + 2, n * 2, n * 2 + 1);
  for (int i = 0; i < n; i++) {
    f.addEdge(n * 2, i, 1, 0);
    f.addEdge(i + n, n * 2 + 1, 2, 0);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i != j && y[i] > y[j]) {
        f.addEdge(j, i + n, 1, dis(i, j));
      }
    }
  }
  pair<int, long double> res = f.maxFlow();
  if (res.first != n - 1) {
    cout << -1 << endl;
  } else {
    printf("%0.17f\n", (double)res.second);
  }
  return 0;
}