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>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
class MinCostMaxFlow {
  int n, m;
  int cap[2 * 170000];
  double cost[2 * 170000], dist[802], pot[802];
  int to[2 * 170000], prev[2 * 170000], last[802], path[802];
  bool used[802];
  priority_queue<pair<double, int> > q;

 public:
  MinCostMaxFlow(int n) {
    this->n = n;
    m = 0;
    for (int i = 0, _n = (n); i < _n; ++i) last[i] = -1;
  }
  void addEdge(int first, int second, int w, double c) {
    cap[m] = w;
    cost[m] = c;
    to[m] = second;
    prev[m] = last[first];
    last[first] = m;
    m++;
    cap[m] = 0;
    cost[m] = -c;
    to[m] = first;
    prev[m] = last[second];
    last[second] = m;
    m++;
  }
  pair<int, double> getFlow(int s, int t) {
    int ansf = 0;
    double ansc = 0;
    while (true) {
      pair<int, double> p = search(s, t);
      if (!used[t]) break;
      ansf += p.first;
      ansc += p.second;
    }
    return make_pair(ansf, ansc);
  }

 protected:
  pair<int, double> search(int s, int t) {
    int ansf = 0;
    double ansc = 0;
    for (int i = 0, _n = (n); i < _n; ++i) used[i] = false, dist[i] = 1.0E+9;
    dist[s] = 0;
    path[s] = -1;
    q.push(make_pair(0, s));
    while (!q.empty()) {
      int first = q.top().second;
      q.pop();
      if (used[first]) continue;
      used[first] = true;
      for (int e = last[first]; e >= 0; e = prev[e])
        if (cap[e] > 0) {
          double tmp = dist[first] + cost[e] + pot[first] - pot[to[e]];
          if (tmp < dist[to[e]] && !used[to[e]]) {
            dist[to[e]] = tmp;
            path[to[e]] = e;
            q.push(make_pair(-dist[to[e]], to[e]));
          }
        }
    }
    for (int i = 0, _n = (n); i < _n; ++i) pot[i] += dist[i];
    if (used[t]) {
      ansf = (1 << 29);
      for (int e = path[t]; e >= 0; e = path[to[e ^ 1]])
        ansf = min(ansf, cap[e]);
      for (int e = path[t]; e >= 0; e = path[to[e ^ 1]]) {
        ansc += cost[e] * ansf;
        cap[e] -= ansf;
        cap[e ^ 1] += ansf;
      }
    }
    return make_pair(ansf, ansc);
  }
};
int X[400];
int Y[400];
void solution() {
  int n;
  scanf("%d", &n);
  for (int i = 0, _n = (n); i < _n; ++i) scanf("%d %d", X + i, Y + i);
  MinCostMaxFlow mf(n * 2 + 2);
  for (int i = 0, _n = (n); i < _n; ++i)
    for (int j = 0, _n = (n); j < _n; ++j)
      if (Y[j] > Y[i]) {
        double dist = sqrt(((X[i] - X[j]) * (X[i] - X[j])) +
                           ((Y[i] - Y[j]) * (Y[i] - Y[j])) + 0.);
        mf.addEdge(i, n + j, 1, dist);
      }
  for (int i = 0, _n = (n); i < _n; ++i) mf.addEdge(n * 2, i, 1, 0);
  for (int i = 0, _n = (n); i < _n; ++i) mf.addEdge(n + i, n * 2 + 1, 2, 0);
  pair<int, double> ret = mf.getFlow(n * 2, n * 2 + 1);
  if (ret.first != n - 1)
    puts("-1");
  else
    printf("%.10lf\n", ret.second);
}
int main() {
  solution();
  return 0;
}