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;
int N, s, t;
int deg[1000], pre[1000];
double d[1000], pi[1000];
int Adj[1000][1000], cap[1000][1000], fnt[1000][1000];
double cst[1000][1000];
int source(int k) { return k * 2; }
int sink(int k) { return k * 2 + 1; }
bool dijkstra(int n) {
  int i, u, v;
  double k;
  for (i = 0; i < n; i++) d[i] = (INT_MAX / 2);
  for (i = 0; i < n; i++) pre[i] = -1;
  d[s] = 0;
  pre[s] = n;
  set<pair<double, int> > PQ;
  PQ.insert(pair<double, int>(d[s], s));
  while (!PQ.empty()) {
    u = PQ.begin()->second;
    k = PQ.begin()->first;
    PQ.erase(PQ.begin());
    if (d[u] != k) continue;
    for (i = 0; i < deg[u]; i++) {
      v = Adj[u][i];
      if (fnt[v][u] && d[v] > (d[u] + pi[u] - pi[v]) - cst[v][u])
        d[v] = (d[u] + pi[u] - pi[v]) - cst[v][pre[v] = u];
      if (fnt[u][v] < cap[u][v] && d[v] > (d[u] + pi[u] - pi[v]) + cst[u][v])
        d[v] = (d[u] + pi[u] - pi[v]) + cst[pre[v] = u][v];
      if (pre[v] == u) PQ.insert(pair<double, int>(d[v], v));
    }
  }
  for (i = 0; i < n; i++)
    if (pi[i] < (INT_MAX / 2)) pi[i] += d[i];
  return pre[t] >= 0;
}
int MFMC(int n, double& fcst) {
  int u, v;
  int flow = 0;
  fcst = 0;
  for (u = 0; u < n; u++)
    for (v = 0; v < n; v++) fnt[u][v] = 0;
  for (u = 0; u < n; u++) pi[u] = deg[u] = 0;
  for (u = 0; u < n; u++)
    for (v = 0; v < n; v++)
      if (cap[u][v] || cap[v][u]) Adj[u][deg[u]++] = v;
  while (dijkstra(n)) {
    int bot = (INT_MAX / 2);
    for (u = pre[v = t]; v != s; u = pre[v = u])
      bot = min(bot, fnt[v][u] ? fnt[v][u] : (cap[u][v] - fnt[u][v]));
    for (u = pre[v = t]; v != s; u = pre[v = u]) {
      if (fnt[v][u]) {
        fnt[v][u] -= bot;
        fcst -= bot * cst[v][u];
      } else {
        fnt[u][v] += bot;
        fcst += bot * cst[u][v];
      }
    }
    flow += bot;
  }
  return flow;
}
int main() {
  std::vector<std::pair<int, int> > coords;
  std::cin >> N;
  for (int i = 0; i < N; i++) {
    int x, y;
    std::cin >> x >> y;
    coords.push_back(std::make_pair(y, x));
  }
  std::sort(coords.begin(), coords.end());
  for (int i = N - 1; i >= 0; i--) {
    for (int j = i - 1; j >= 0; j--) {
      if (coords[j].first == coords[i].first) continue;
      int xd = coords[j].second - coords[i].second;
      int yd = coords[j].first - coords[i].first;
      double d = std::sqrt(xd * xd + yd * yd);
      cap[source(i)][sink(j)] = 1;
      cst[source(i)][sink(j)] = d;
    }
    cap[800][source(i)] = 2;
    cap[sink(i)][801] = 1;
  }
  int f;
  s = 800;
  t = 801;
  double cost;
  f = MFMC(802, cost);
  if (f != N - 1)
    std::cout << "-1" << std::endl;
  else {
    std::printf("%.8f\n", cost);
  }
  return 0;
}