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 oo = 1e17;
struct edge {
  int x, y, cap, flow;
  double cost;
};
struct MinCostMaxFlow {
  int n, S, T;
  vector<vector<int> > a;
  vector<int> prev, done;
  vector<double> dist, pot;
  vector<edge> e;
  MinCostMaxFlow() {}
  MinCostMaxFlow(int _n, int _S, int _T) {
    n = _n;
    S = _S;
    T = _T;
    a = vector<vector<int> >(n + 1);
    dist = vector<double>(n + 1);
    prev = vector<int>(n + 1);
    done = vector<int>(n + 1);
    pot = vector<double>(n + 1, 0);
  }
  void addEdge(int x, int y, int _cap, double _cost) {
    edge e1 = {x, y, _cap, 0, _cost};
    edge e2 = {y, x, 0, 0, -_cost};
    a[x].push_back(e.size());
    e.push_back(e1);
    a[y].push_back(e.size());
    e.push_back(e2);
  }
  pair<int, double> dijkstra() {
    int flow = 0;
    double cost = 0;
    for (int i = 1; i <= n; i++) done[i] = 0, dist[i] = oo;
    priority_queue<pair<double, int> > q;
    dist[S] = 0;
    prev[S] = -1;
    q.push(make_pair(0, S));
    while (!q.empty()) {
      int x = q.top().second;
      q.pop();
      if (done[x]) continue;
      done[x] = 1;
      for (int i = 0; i < int(a[x].size()); i++) {
        int id = a[x][i], y = e[id].y;
        if (e[id].flow < e[id].cap) {
          double D = dist[x] + e[id].cost + pot[x] - pot[y];
          if (!done[y] && D < dist[y]) {
            dist[y] = D;
            prev[y] = id;
            q.push(make_pair(-dist[y], y));
          }
        }
      }
    }
    for (int i = 1; i <= n; i++) pot[i] += dist[i];
    if (done[T]) {
      flow = 1 << 29;
      for (int id = prev[T]; id >= 0; id = prev[e[id].x])
        flow = min(flow, e[id].cap - e[id].flow);
      for (int id = prev[T]; id >= 0; id = prev[e[id].x]) {
        cost += e[id].cost * flow;
        e[id].flow += flow;
        e[id ^ 1].flow -= flow;
      }
    }
    return make_pair(flow, cost);
  }
  pair<int, double> minCostMaxFlow() {
    int totalFlow = 0;
    double totalCost = 0;
    while (1) {
      pair<int, double> u = dijkstra();
      if (!done[T]) break;
      totalFlow += u.first;
      totalCost += u.second;
    }
    return make_pair(totalFlow, totalCost);
  }
};
int main() {
  int n, x[444], y[444];
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> x[i] >> y[i];
  int S = n * 2 + 1, T = S + 1;
  MinCostMaxFlow F(T, S, T);
  for (int i = 1; i <= n; i++) F.addEdge(S, i, 2, 0);
  for (int i = 1; i <= n; i++) F.addEdge(i + n, T, 1, 0);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (y[i] > y[j])
        F.addEdge(i, j + n, 1,
                  sqrt(((x[i] - x[j]) * (x[i] - x[j])) +
                       ((y[i] - y[j]) * (y[i] - y[j]))));
  pair<int, double> ans = F.minCostMaxFlow();
  if (ans.first < n - 1)
    puts("-1");
  else
    printf("%.9lf\n", ans.second);
}