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 long long INF = 1e9;
struct MCF {
  int n;
  vector<long double> prio, pot;
  vector<long long> curflow;
  vector<int> prevedge, prevnode;
  priority_queue<pair<long double, int>, vector<pair<long double, int>>,
                 greater<pair<long double, int>>>
      q;
  struct edge {
    int to, rev;
    long long f, cap;
    long double cost;
  };
  vector<vector<edge>> g;
  MCF(int n)
      : n(n), prio(n), curflow(n), prevedge(n), prevnode(n), pot(n), g(n) {}
  void add_edge(int s, int t, long long cap, long double cost) {
    g[s].push_back((edge){t, ((int)g[t].size()), 0, cap, cost});
    g[t].push_back((edge){s, ((int)g[s].size()) - 1, 0, 0, -cost});
  }
  pair<long long, long double> get_flow(int s, int t) {
    long long flow = 0;
    long double flowcost = 0;
    while (1) {
      q.push({0, s});
      fill(prio.begin(), prio.end(), INF);
      prio[s] = 0;
      curflow[s] = INF;
      while (!q.empty()) {
        auto cur = q.top();
        long double d = cur.first;
        int u = cur.second;
        q.pop();
        if (d != prio[u]) continue;
        for (int i = 0; i < ((int)g[u].size()); ++i) {
          edge& e = g[u][i];
          int v = e.to;
          if (e.cap <= e.f) continue;
          long double nprio = prio[u] + e.cost + pot[u] - pot[v];
          if (prio[v] > nprio) {
            prio[v] = nprio;
            q.push({nprio, v});
            prevnode[v] = u;
            prevedge[v] = i;
            curflow[v] = min(curflow[u], e.cap - e.f);
          }
        }
      }
      if (prio[t] == INF) break;
      for (int i = 0; i < n; i++) pot[i] += prio[i];
      long long df = min(curflow[t], INF - flow);
      flow += df;
      for (int v = t; v != s; v = prevnode[v]) {
        edge& e = g[prevnode[v]][prevedge[v]];
        e.f += df;
        g[v][e.rev].f -= df;
        flowcost += df * e.cost;
      }
    }
    return {flow, flowcost};
  }
};
long double get(pair<int, int>& a, pair<int, int>& b) {
  long double x = b.first - a.first;
  long double y = b.second - a.second;
  return sqrt(x * x + y * y);
}
int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> v;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    v.push_back({x, y});
  }
  MCF mcf(2 * n + 2);
  for (int i = 0; i < n; i++) {
    mcf.add_edge(2 * n, i, 2, 0);
    mcf.add_edge(i + n, 2 * n + 1, 1, 0);
    for (int j = 0; j < n; j++)
      if (i != j && v[i].second > v[j].second) {
        mcf.add_edge(i, j + n, 1, get(v[i], v[j]));
      }
  }
  auto p = mcf.get_flow(2 * n, 2 * n + 1);
  if (p.first != n - 1)
    cout << -1 << endl;
  else {
    cout.precision(20);
    cout << p.second << endl;
  }
  return 0;
}