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 = 5e5 + 10;
const int mod = 1e9 + 7;
const int inf = (1 << 30);
const int block = 316;
long long n, flow;
long double mincost;
long long to[maxn], cap[maxn], pre[maxn], last[maxn], pos[maxn];
long double cost[maxn];
long long par[maxn];
long double dis[maxn];
int dfs(int source, int sink, long long untilnow) {
  if (source == sink) return untilnow;
  int now = 0;
  for (long long &ed = pos[source]; ed != -1; ed = pre[ed]) {
    if (cap[ed] and par[to[ed]] == source) {
      long long cur = dfs(to[ed], sink, min(cap[ed], untilnow));
      cap[ed] -= cur, cap[ed ^ 1] += cur, mincost += cost[ed] * cur, now += cur,
          untilnow -= cur;
      if (untilnow == 0) return now;
    }
  }
  return now;
}
bool mark[maxn];
bool bfs(int source, int sink) {
  memset(par, -1, sizeof par);
  for (int i = source; i <= sink; i++) dis[i] = inf;
  dis[source] = 0;
  queue<int> Q;
  Q.push(source);
  mark[source] = 1;
  while (!Q.empty()) {
    int cur = Q.front();
    Q.pop();
    mark[cur] = 0;
    for (int ed = last[cur]; ed != -1; ed = pre[ed]) {
      if (cap[ed] and dis[to[ed]] > dis[cur] + cost[ed]) {
        dis[to[ed]] = dis[cur] + cost[ed];
        par[to[ed]] = cur;
        if (!mark[to[ed]]) {
          Q.push(to[ed]);
          mark[to[ed]] = 1;
        }
      }
    }
  }
  return par[sink] != -1;
}
void maxFlow() {
  int source = 1, sink = 1 + 2 * n + 1;
  while (bfs(source, sink)) {
    for (int i = source; i <= sink; i++) pos[i] = last[i];
    flow += dfs(source, sink, inf);
  }
}
int cnt = 0;
void addEdge(int fi, int se, int ca, long double co) {
  to[cnt] = se, cap[cnt] = ca, cost[cnt] = co, pre[cnt] = last[fi],
  last[fi] = cnt++;
  to[cnt] = fi, cap[cnt] = 0, cost[cnt] = -co, pre[cnt] = last[se],
  last[se] = cnt++;
}
int x[maxn], y[maxn];
long double DIS(int i, int j) {
  long double xx = abs(x[i] - x[j]), yy = abs(y[i] - y[j]);
  return sqrt(1.0 * xx * xx + yy * yy);
}
int main() {
  ios_base::sync_with_stdio(false);
  memset(last, -1, sizeof last);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> x[i] >> y[i];
  int source = 1, sink = 1 + 2 * n + 1;
  for (int i = 1; i <= n; i++) addEdge(source, 1 + i, 2, 0);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (y[i] > y[j]) addEdge(1 + i, 1 + n + j, 1, DIS(i, j));
  for (int i = 1; i <= n; i++) addEdge(1 + n + i, sink, 1, 0);
  maxFlow();
  if (flow == n - 1)
    cout << fixed << setprecision(12) << mincost << endl;
  else
    cout << -1 << endl;
  return 0;
}