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 = 405;
struct edge {
  int x, y, flow, cap, nxt;
  double cost;
};
struct gragh {
  static const int N = 1000, M = N * N * 2;
  int n, m, S, T, lim, fst[N], f[N], a[N], p[N], q[N];
  double d[N];
  edge e[M];
  void init(int _n, int _lim) {
    n = _n, m = 1, lim = _lim;
    memset(fst, 0, sizeof fst);
  }
  void add(int a, int b, int cap, double cost) {
    m++;
    e[m].x = a, e[m].y = b, e[m].cap = cap, e[m].cost = cost, e[m].flow = 0;
    e[m].nxt = fst[a], fst[a] = m;
    m++;
    e[m].x = b, e[m].y = a, e[m].cap = 0, e[m].cost = -cost, e[m].flow = 0;
    e[m].nxt = fst[b], fst[b] = m;
  }
  bool SPFA(int S, int T, int &flow, double &cost) {
    int head = 0, tail = 0, qmod = n + 1, x, y;
    memset(f, 0, sizeof f);
    for (int i = 1; i <= n; i++) d[i] = 1e100;
    d[S] = 0, q[tail = tail % qmod + 1] = S, a[S] = 2e9;
    while (head != tail) {
      f[x = q[head = head % qmod + 1]] = 0;
      for (int i = fst[x]; i; i = e[i].nxt) {
        y = e[i].y;
        if (e[i].flow < e[i].cap && d[x] + e[i].cost < d[y]) {
          d[y] = d[x] + e[i].cost;
          a[y] = min(a[x], e[i].cap - e[i].flow);
          p[y] = i;
          if (!f[y]) f[q[tail = tail % qmod + 1] = y] = 1;
        }
      }
    }
    if (d[T] > 1e90) return 0;
    flow += a[T], cost += d[T] * a[T], x = T;
    for (x = T; x != S; x = e[p[x]].x)
      e[p[x]].flow += a[T], e[p[x] ^ 1].flow -= a[T];
    return 1;
  }
  double MinCost(int S, int T) {
    int flow = 0;
    double cost = 0;
    while (SPFA(S, T, flow, cost))
      ;
    if (flow < lim) return -1;
    return cost;
  }
} g;
int n, x[N], y[N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d%d", &x[i], &y[i]);
  g.init(n * 2 + 2, n - 1);
  int S = n * 2 + 1, T = n * 2 + 2;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (y[i] > y[j])
        g.add(i, j + n, 1,
              sqrt((x[i] - x[j]) * (x[i] - x[j]) +
                   (y[i] - y[j]) * (y[i] - y[j])));
  for (int i = 1; i <= n; i++) g.add(S, i, 2, 0), g.add(i + n, T, 1, 0);
  double res = g.MinCost(S, T);
  if (res < 0)
    puts("-1");
  else
    printf("%.10lf", res);
  return 0;
}