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 MAXN = 2000015;
const int MOD = 1000000007;
struct MinCostMaxFlow {
  int N;
  vector<vector<int> > G;
  vector<vector<long long int> > cap, flow;
  vector<vector<double> > cost;
  vector<double> dist;
  vector<int> found;
  vector<int> dad;
  MinCostMaxFlow(int N)
      : N(N),
        G(N),
        cap(N, vector<long long int>(N)),
        flow(N, vector<long long int>(N)),
        cost(N, vector<double>(N)),
        found(N),
        dist(N),
        dad(N) {}
  void add_edge(int from, int to, long long int capacity, double c) {
    G[from].push_back(to);
    G[to].push_back(from);
    cap[from][to] = capacity;
    cap[to][from] = 0;
    cost[from][to] = c;
    cost[to][from] = -1 * c;
  }
  bool relax_edge(int u, int v) {
    if (dist[u] + cost[u][v] < dist[v]) {
      dad[v] = u;
      dist[v] = dist[u] + cost[u][v];
      return true;
    }
    return false;
  }
  bool bellmanford(int s, int t) {
    int u, v;
    fill(dad.begin(), dad.end(), -1);
    fill(dist.begin(), dist.end(), (double)1e9);
    fill(found.begin(), found.end(), 0);
    queue<int> Q;
    dad[s] = s;
    dist[s] = 0.0;
    Q.push(s);
    found[s] = true;
    while (!Q.empty()) {
      u = Q.front();
      found[u] = false;
      Q.pop();
      if (u == t) continue;
      for (int i = 0; i <= ((int)(G[u].size())) - 1; i++) {
        v = G[u][i];
        if (cap[u][v] <= flow[u][v]) continue;
        if (relax_edge(u, v) and !found[v]) Q.push(v), found[v] = true;
      }
    }
    return (dad[t] != -1);
  }
  pair<long long int, double> GetMaxFlow(int s, int t) {
    long long int totflow = 0;
    double totcost = 0.0;
    while (bellmanford(s, t)) {
      for (int x = t; x != s; x = dad[x]) {
        flow[dad[x]][x]++;
        flow[x][dad[x]]--;
      }
      totflow++;
      totcost += dist[t];
    }
    return make_pair(totflow, totcost);
  }
};
vector<pair<int, int> > P;
double getdist(int i, int j) {
  return sqrt((P[i].first - P[j].first) * (P[i].first - P[j].first) +
              (P[i].second - P[j].second) * (P[i].second - P[j].second));
}
int main() {
  int n, x, y;
  scanf("%d", &n);
  MinCostMaxFlow F(2 * n + 2);
  int source = 0;
  int sink = 2 * n + 1;
  int ma = -1;
  for (int i = 0; i <= n - 1; i++) {
    scanf("%d", &x), scanf("%d", &y);
    P.push_back(pair<int, int>(x, y));
    ma = max(y, ma);
  }
  int c = 0;
  for (int i = 0; i <= n - 1; i++) {
    if (P[i].second == ma) c++;
  }
  if (c != 1) {
    cout << -1 << "\n";
    return 0;
  }
  for (int i = 0; i <= n - 1; i++) {
    F.add_edge(source, i + 1, 2, 0.0);
    F.add_edge(n + 1 + i, sink, 1, 0.0);
  }
  for (int i = 0; i <= n - 1; i++)
    for (int j = 0; j <= n - 1; j++) {
      if (P[i].second > P[j].second) {
        F.add_edge(i + 1, n + j + 1, 1, getdist(i, j));
      }
    }
  pair<long long int, double> ans = F.GetMaxFlow(source, sink);
  if (ans.first != n - 1)
    cout << -1 << "\n";
  else
    printf("%0.10lf\n", ans.second);
  return 0;
}