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 long long INF = 1 << 28;
const long long LINF = 1ll << 61;
inline long long getnum() {
  register long long r = 0;
  register bool ng = 0;
  register char c;
  c = getchar();
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  if (c == '-') ng = 1, c = getchar();
  while (c != ' ' && c != '\n') r = r * 10 + c - '0', c = getchar();
  if (ng) r = -r;
  return r;
}
template <class T>
inline void putnum(T x) {
  if (x < 0) putchar('-'), x = -x;
  register short a[20] = {}, sz = 0;
  while (x > 0) a[sz++] = x % 10, x /= 10;
  if (sz == 0) putchar('0');
  for (int i = sz - 1; i >= 0; i--) putchar('0' + a[i]);
}
inline void putsp() { putchar(' '); }
inline void putendl() { putchar('\n'); }
inline char mygetchar() {
  register char c = getchar();
  while (c == ' ' || c == '\n') c = getchar();
  return c;
}
int n, x[411], y[411];
const int maxnx = 411;
const int maxny = 811;
const double eps = 1e-7;
struct KM {
  int nx, ny, mx[maxnx], my[maxny];
  bool visx[maxnx], visy[maxny];
  vector<pair<int, double> > con[maxnx];
  double lx[maxnx], ly[maxny], slack[maxny];
  void init(int xx, int yy) {
    nx = xx;
    ny = yy;
    for (int i = 0; i < maxnx; i++) con[i].clear();
    memset(mx, -1, sizeof(mx));
    memset(my, -1, sizeof(my));
  }
  void add_edge(int x, int y, double d) { con[x].push_back(make_pair(y, d)); }
  bool dfs(int x) {
    visx[x] = 1;
    for (int i = 0; i < con[x].size(); i++) {
      int y = con[x][i].first;
      double w = con[x][i].second;
      if (lx[x] + ly[y] - eps > w) {
        slack[y] = min(slack[y], lx[x] + ly[y] - w);
      } else if (!visy[y]) {
        visy[y] = 1;
        if (my[y] == -1 || dfs(my[y])) {
          mx[x] = y;
          my[y] = x;
          return true;
        }
      }
    }
    return false;
  }
  bool godfs(int x) {
    memset(visx, 0, sizeof(visx));
    memset(visy, 0, sizeof(visy));
    for (int i = 0; i < maxny; i++) slack[i] = 1e40;
    return dfs(x);
  }
  pair<int, double> matching() {
    int failed = 0;
    for (int i = 1; i <= nx; i++) {
      lx[i] = -1e40;
      for (int j = 0; j < con[i].size(); j++)
        lx[i] = max(lx[i], con[i][j].second);
    }
    for (int i = 1; i <= ny; i++) ly[i] = 0;
    for (int i = 1; i <= nx; i++) {
      while (!godfs(i)) {
        double d = 1e40;
        for (int j = 1; j <= ny; j++)
          if (!visy[j]) d = min(d, slack[j]);
        if (d == 1e40) {
          failed++;
          break;
        }
        for (int j = 1; j <= nx; j++)
          if (visx[j]) lx[j] -= d;
        for (int j = 1; j <= ny; j++)
          if (visy[j]) ly[j] += d;
      }
    }
    double cost = 0;
    for (int i = 1; i <= nx; i++) {
      for (int j = 0; j < con[i].size(); j++) {
        if (con[i][j].first == mx[i]) {
          cost += con[i][j].second;
        }
      }
    }
    return make_pair(nx - failed, cost);
  }
} km;
int main() {
  n = getnum();
  for (int i = 1; i <= n; i++) {
    x[i] = getnum(), y[i] = getnum();
  }
  km.init(n, 2 * n);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (y[i] < y[j]) {
        double dis =
            sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
        km.add_edge(i, j, -dis);
        km.add_edge(i, j + n, -dis);
      }
    }
  }
  pair<int, double> ans = km.matching();
  if (ans.first != n - 1)
    puts("-1");
  else
    cout << fixed << setprecision(12) << -ans.second << endl;
  return 0;
}