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;
struct Point {
  int x, y;
  Point(int x, int y) {
    this->x = x;
    this->y = y;
  }
  double dist(Point p1) {
    return sqrt(double((p1.x - x) * (p1.x - x) + (p1.y - y) * (p1.y - y)));
  }
};
struct Value {
  int cap;
  double cost;
  int F;
  void assign(int cap, double cost, int F = 0) {
    this->cap = cap;
    this->cost = cost;
    this->F = F;
  }
  int UPI() { return cap - F; }
};
class Graph {
 private:
  vector<vector<Value> > v;
  int n;
  int source, sink;

 public:
  Graph(int n, vector<Point> p) {
    this->n = n;
    Value val;
    val.assign(0, 1e7);
    vector<Value> vv(2 * n + 2, val);
    v.assign(2 * n + 2, vv);
    source = n << 1;
    sink = (n << 1) + 1;
    for (int i = 0; i < p.size(); ++i) {
      v[source][i << 1].assign(2, 0);
      v[i << 1][source].assign(0, 0);
      v[(i << 1) + 1][sink].assign(1, 0);
      v[sink][(i << 1) + 1].assign(0, 0);
    }
    for (int i = 0; i < p.size(); ++i) {
      for (int j = 0; j < p.size(); ++j) {
        if (p[i].y > p[j].y) {
          v[i << 1][(j << 1) + 1].assign(1, p[i].dist(p[j]));
          v[(j << 1) + 1][i << 1].assign(0, -p[i].dist(p[j]));
        }
      }
    }
  }
  double min_cost_flow(int flow) {
    double cost = 0;
    while (flow > 0) {
      vector<int> par(2 * n + 2, 1e7);
      vector<double> dist(2 * n + 2, 1e7);
      vector<int> ID(2 * n + 2, 2);
      list<int> Q;
      Q.push_back(source);
      ID[source] = 1;
      dist[source] = 0;
      for (list<int>::iterator it = Q.begin(); it != Q.end(); it = Q.begin()) {
        int cur_i = *it;
        Q.pop_front();
        for (int i = 0; i < 2 * n + 2; i++) {
          if (v[cur_i][i].cost < 1e7 && v[cur_i][i].UPI() > 0) {
            if (ID[i] == 0) {
              if (dist[i] > dist[cur_i] + v[cur_i][i].cost) {
                ID[i] = 1;
                Q.push_front(i);
                dist[i] = dist[cur_i] + v[cur_i][i].cost;
                par[i] = cur_i;
              }
              continue;
            }
            if (ID[i] == 2) {
              ID[i] = 1;
              Q.push_back(i);
              dist[i] = dist[cur_i] + v[cur_i][i].cost;
              par[i] = cur_i;
              continue;
            }
            if (dist[i] > dist[cur_i] + v[cur_i][i].cost) {
              dist[i] = dist[cur_i] + v[cur_i][i].cost;
              par[i] = cur_i;
            }
          }
        }
        ID[cur_i] = 0;
      }
      if (par[sink] == 1e7) {
        return -1;
      }
      assert(dist[sink] < 1e7);
      for (int cur = sink; cur != source; cur = par[cur]) {
        int pred = par[cur];
        assert(v[pred][cur].UPI() > 0);
        v[pred][cur].F++;
        v[cur][pred].F--;
        cost += v[pred][cur].cost;
      }
      flow--;
    }
    return cost;
  }
};
int main() {
  int n;
  cin >> n;
  vector<Point> p;
  for (int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    p.push_back(Point(x, y));
  }
  Graph G(n, p);
  cout << setprecision(7) << G.min_cost_flow(p.size() - 1) << endl;
  return 0;
}