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 INF = 1e9;
const int MOD = 1e9 + 7;
const long long INF64 = 2e18;
const long double EPS = 1e-7;
mt19937 myrand(time(NULL));
const int N = 1000 + 13;
const int M = 400 * 1000 + 13;
struct edge {
  int v, u;
  double w;
  int cap, flow;
  edge(){};
  edge(int v, int u, double w, int cap, int flow)
      : v(v), u(u), w(w), cap(cap), flow(flow){};
};
int n, rn;
vector<int> g[N];
int lst;
edge e[M];
int s, t;
pair<int, int> a[N];
int rem(int it) { return e[it].cap - e[it].flow; }
void add_edge(int v, int u, double w, int cap) {
  g[v].push_back(lst);
  e[lst++] = edge(v, u, w, cap, 0);
  g[u].push_back(lst);
  e[lst++] = edge(u, v, -w, 0, 0);
}
bool read() {
  if (scanf("%d", &rn) != 1) return 0;
  lst = 0;
  s = 2 * rn, t = s + 1;
  n = t + 1;
  for (int i = 0; i < (n); i++) g[i].clear();
  for (int i = 0; i < (rn); i++) scanf("%d%d", &a[i].first, &a[i].second);
  return 1;
}
double f[N];
void FB(int v) {
  for (int i = 0; i < (n); i++) f[i] = INF;
  f[v] = 0;
  while (true) {
    bool fl = false;
    for (int i = 0; i < (lst); i++)
      if (f[e[i].u] > f[e[i].v] + e[i].w && rem(i)) {
        f[e[i].u] = f[e[i].v] + e[i].w;
        fl = true;
      }
    if (!fl) break;
  }
}
double d[N];
int pr[N];
void Dijkstra(int v) {
  for (int i = 0; i < (n); i++) {
    d[i] = INF;
    pr[i] = -1;
  }
  d[v] = 0;
  set<pair<double, int> > q;
  q.insert(make_pair(d[v], v));
  while (!q.empty()) {
    auto cur = *q.begin();
    q.erase(q.begin());
    for (auto it : g[cur.second]) {
      int first = e[it].v;
      int second = e[it].u;
      if (d[second] > d[first] + e[it].w && rem(it) != 0) {
        q.erase(make_pair(d[second], second));
        d[second] = d[first] + e[it].w;
        pr[second] = it;
        q.insert(make_pair(d[second], second));
      }
    }
  }
}
int res;
double minc() {
  double ans = 0;
  while (true) {
    Dijkstra(s);
    int cur = t;
    int add = INF;
    double len = 0;
    while (pr[cur] != -1) {
      add = min(add, rem(pr[cur]));
      len += e[pr[cur]].w;
      cur = e[pr[cur]].v;
    }
    if (add == 0 || pr[t] == -1) break;
    cur = t;
    while (pr[cur] != -1) {
      e[pr[cur]].flow += add;
      e[pr[cur] ^ 1].flow -= add;
      cur = e[pr[cur]].v;
    }
    res += add;
    ans += add * len;
  }
  return ans;
}
double get(int i, int j) {
  return sqrtl((a[i].first - a[j].first) * (a[i].first - a[j].first) +
               (a[i].second - a[j].second) * (a[i].second - a[j].second));
}
void solve() {
  for (int i = 0; i < (rn); i++)
    for (int j = 0; j < (rn); j++)
      if (a[i].second > a[j].second) add_edge(i, rn + j, get(i, j), 1);
  for (int i = 0; i < (rn); i++) add_edge(s, i, 0, 2);
  for (int i = 0; i < (rn); i++) add_edge(rn + i, t, 0, 1);
  res = 0;
  double ans = minc();
  if (res != rn - 1) {
    printf("-1\n");
    return;
  }
  printf("%.15f\n", ans);
}
int main() {
  while (read()) solve();
}