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 cap[1000][1000];
double cost[1000][1000];
int fnet[1000][1000], adj[1000][1000], deg[1000];
int par[1000];
double d[1000];
int q[1000], inq[1000], qs;
double pi[1000];
bool dijkstra(int n, int s, int t) {
  for (int i = 0; i < 1000; ++i) d[i] = 1e20;
  memset(par, -1, sizeof(par));
  memset(inq, -1, sizeof(inq));
  d[s] = qs = 0;
  inq[q[qs++] = s] = 0;
  par[s] = n;
  while (qs) {
    int u = q[0];
    inq[u] = -1;
    q[0] = q[--qs];
    if (qs) inq[q[0]] = 0;
    for (int i = 0, j = 2 * i + 1, t; j < qs; i = j, j = 2 * i + 1) {
      if (j + 1 < qs && d[q[j + 1]] < d[q[j]]) j++;
      if (d[q[j]] + 1e-9 >= d[q[i]]) break;
      {
        t = q[i];
        q[i] = q[j];
        q[j] = t;
        t = inq[q[i]];
        inq[q[i]] = inq[q[j]];
        inq[q[j]] = t;
      };
    }
    for (int k = 0, v = adj[u][k]; k < deg[u]; v = adj[u][++k]) {
      if (fnet[v][u] && d[v] > (d[u] + pi[u] - pi[v]) - cost[v][u])
        d[v] = (d[u] + pi[u] - pi[v]) - cost[v][par[v] = u];
      if (fnet[u][v] < cap[u][v] &&
          d[v] - 1e-9 > (d[u] + pi[u] - pi[v]) + cost[u][v])
        d[v] = (d[u] + pi[u] - pi[v]) + cost[par[v] = u][v];
      if (par[v] == u) {
        if (inq[v] < 0) {
          inq[q[qs] = v] = qs;
          qs++;
        }
        for (int i = inq[v], j = (i - 1) / 2, t; d[q[i]] < d[q[j]] - 1e-9;
             i = j, j = (i - 1) / 2) {
          t = q[i];
          q[i] = q[j];
          q[j] = t;
          t = inq[q[i]];
          inq[q[i]] = inq[q[j]];
          inq[q[j]] = t;
        };
      }
    }
  }
  for (int i = 0; i < n; i++)
    if (pi[i] < 1e20) pi[i] += d[i];
  return par[t] >= 0;
}
int mcmf4(int n, int s, int t, double &fcost) {
  memset(deg, 0, sizeof(deg));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (cap[i][j] || cap[j][i]) adj[i][deg[i]++] = j;
  memset(fnet, 0, sizeof(fnet)), memset(pi, 0, sizeof(pi));
  int flow = fcost = 0;
  while (dijkstra(n, s, t)) {
    int bot = (1 << 30);
    for (int v = t, u = par[v]; v != s; u = par[v = u])
      bot = min(bot, fnet[v][u] ? fnet[v][u] : (cap[u][v] - fnet[u][v]));
    for (int v = t, u = par[v]; v != s; u = par[v = u])
      if (fnet[v][u]) {
        fnet[v][u] -= bot;
        fcost -= bot * cost[v][u];
      } else {
        fnet[u][v] += bot;
        fcost += bot * cost[u][v];
      }
    flow += bot;
  }
  return flow;
}
double sqr(double x) { return x * x; }
int x[500], y[500];
int n, second, E;
int main() {
  scanf("%d", &n), second = 0, E = 2 * n + 1;
  for (int i = 1; i <= n; ++i) scanf("%d%d", x + i, y + i);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      if (y[i] > y[j])
        cap[i][j + n] = 1,
                   cost[i][j + n] = sqrt(sqr(x[i] - x[j]) + sqr(y[i] - y[j]));
  for (int i = 1; i <= n; ++i) cap[second][i] = 2, cap[i + n][E] = 1;
  double ans;
  int flow = mcmf4(E + 1, second, E, ans);
  if (flow != n - 1)
    printf("-1");
  else
    printf("%.10lf", ans);
  return 0;
}