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 N = 850;
int capacity[N][N], p[N], visit[N], n, source, sink, max_flow;
pair<int, int> a[N];
vector<int> adj[N];
double f[N], cost[N][N], res;
double dis(pair<int, int> a, pair<int, int> b) {
  return sqrt((a.first - b.first) * (a.first - b.first) +
              (a.second - b.second) * (a.second - b.second));
}
void add(int u, int v, int cap, double c) {
  adj[u].push_back(v);
  adj[v].push_back(u);
  capacity[u][v] = cap;
  cost[u][v] = c;
  cost[v][u] = -c;
}
int bfs() {
  for (int i = 0; i <= 2 * n + 1; i++) {
    visit[i] = 2;
    f[i] = 1e9;
  }
  f[source] = 0;
  deque<int> q;
  q.push_back(source);
  int check = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop_front();
    visit[u] = 0;
    if (u == sink) check = 1;
    for (int v : adj[u])
      if (capacity[u][v] > 0 && f[v] > f[u] + cost[u][v]) {
        f[v] = f[u] + cost[u][v];
        p[v] = u;
        if (visit[v] == 1) continue;
        if (visit[v] == 2)
          q.push_back(v);
        else
          q.push_front(v);
      }
  }
  return check;
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  source = 0;
  sink = 2 * n + 1;
  for (int i = 1; i <= n; i++) cin >> a[i].first >> a[i].second;
  for (int i = 1; i <= n; i++) add(source, i, 2, 0);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (a[i].second > a[j].second) add(i, j + n, 1, dis(a[i], a[j]));
  for (int i = n + 1; i <= 2 * n; i++) add(i, sink, 1, 0);
  while (bfs()) {
    int flow_path = 1e9, v = sink;
    while (v != source) {
      flow_path = min(flow_path, capacity[p[v]][v]);
      v = p[v];
    }
    v = sink;
    max_flow += flow_path;
    res += flow_path * f[sink];
    while (v != source) {
      capacity[p[v]][v] -= flow_path;
      capacity[v][p[v]] += flow_path;
      v = p[v];
    }
  }
  cout << fixed << setprecision(9);
  if (max_flow != n - 1)
    cout << -1;
  else
    cout << res;
}