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 MOD = 1e9 + 7;
struct edge {
  int to, flow, rev;
  double cost;
  edge(int a, int b, double c, int d) : to(a), flow(b), cost(c), rev(d) {}
};
int n, depth[10010], now[10010];
vector<edge> g[10010];
queue<int> qq;
void add_edge(int x, int y, int flow, double cost) {
  g[x].push_back(edge(y, flow, cost, (int)g[y].size()));
  g[y].push_back(edge(x, 0, -cost, (int)g[x].size() - 1));
}
void bfs(int s) {
  for (int i = 1; i <= n; i++) depth[i] = -1;
  depth[s] = 0;
  qq.push(s);
  while (!qq.empty()) {
    int f = qq.front();
    qq.pop();
    for (int i = 0; i < g[f].size(); i++) {
      if (g[f][i].flow == 0 || depth[g[f][i].to] > -1) continue;
      depth[g[f][i].to] = depth[f] + 1;
      qq.push(g[f][i].to);
    }
  }
}
int dfs(int pos, int t, int flow) {
  if (pos == t) return flow;
  int flow2;
  for (int i = now[pos]; i < g[pos].size(); i++, now[pos]++) {
    if (g[pos][i].flow == 0 || depth[pos] >= depth[g[pos][i].to]) continue;
    flow2 = dfs(g[pos][i].to, t, min(flow, g[pos][i].flow));
    if (flow2 > 0) {
      g[pos][i].flow -= flow2;
      g[g[pos][i].to][g[pos][i].rev].flow += flow2;
      return flow2;
    }
  }
  return 0;
}
int max_flow(int s, int t) {
  int ret = 0;
  int f;
  while (true) {
    bfs(s);
    if (depth[t] == -1) return ret;
    memset(now, 0, sizeof(now));
    while (true) {
      f = dfs(s, t, INT_MAX);
      if (f == 0) break;
      ret += f;
    }
  }
}
int prevv[10010], preve[10010];
double dist[10010], h[10010];
vector<pair<pair<int, int>, pair<int, double> > > que;
multiset<pair<double, int> > q;
double min_cost_flow(int s, int t, int f) {
  double ret = 0;
  while (f > 0) {
    for (int i = 0; i < n + 5; i++) dist[i] = 1e12;
    dist[s] = 0;
    q.insert(make_pair(0, s));
    while (!q.empty()) {
      pair<double, int> p = *q.begin();
      q.erase(q.begin());
      if (p.first > dist[p.second]) continue;
      for (int i = 0; i < g[p.second].size(); i++) {
        if (g[p.second][i].flow == 0 ||
            dist[g[p.second][i].to] <= p.first + g[p.second][i].cost +
                                           h[p.second] - h[g[p.second][i].to])
          continue;
        dist[g[p.second][i].to] = (double)p.first + g[p.second][i].cost +
                                  h[p.second] - h[g[p.second][i].to];
        prevv[g[p.second][i].to] = p.second;
        preve[g[p.second][i].to] = i;
        q.insert(make_pair(dist[g[p.second][i].to], g[p.second][i].to));
      }
    }
    for (int i = 1; i <= n; i++) h[i] += dist[i];
    int curf = f;
    for (int pos = t; pos != s; pos = prevv[pos])
      curf = min(curf, g[prevv[pos]][preve[pos]].flow);
    f -= curf;
    ret += h[t] * (double)curf;
    for (int pos = t; pos != s; pos = prevv[pos]) {
      g[prevv[pos]][preve[pos]].flow -= curf;
      g[pos][g[prevv[pos]][preve[pos]].rev].flow += curf;
    }
  }
  return ret;
}
int x[410], y[410];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
  for (int i = 1; i <= n; i++) {
    add_edge(n + n + 1, i, 2, 0);
    add_edge(i + n, n + n + 2, 1, 0);
    que.push_back(make_pair(make_pair(n + n + 1, i), make_pair(2, 0)));
    que.push_back(make_pair(make_pair(i + n, n + n + 2), make_pair(1, 0)));
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (y[i] <= y[j]) continue;
      add_edge(i + 1, j + n + 1, 1,
               sqrt(abs(x[i] - x[j]) * abs(x[i] - x[j]) +
                    abs(y[i] - y[j]) * abs(y[i] - y[j])));
      que.push_back(
          make_pair(make_pair(i + 1, j + n + 1),
                    make_pair(1, sqrt(abs(x[i] - x[j]) * abs(x[i] - x[j]) +
                                      abs(y[i] - y[j]) * abs(y[i] - y[j])))));
    }
  n = n + n + 2;
  int f = max_flow(n - 1, n);
  if (f != (n - 2) / 2 - 1) {
    puts("-1");
    return 0;
  }
  for (int i = 1; i <= n; i++) g[i].clear();
  for (int i = 0; i < que.size(); i++)
    add_edge(que[i].first.first, que[i].first.second, que[i].second.first,
             que[i].second.second);
  printf("%.10lf\n", min_cost_flow(n - 1, n, f));
  return 0;
}