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;
inline int Rd() {
  int ret = 0, fu = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') fu = -1;
    ch = getchar();
  }
  while (isdigit(ch)) ret = ret * 10 + (ch - '0'), ch = getchar();
  return ret * fu;
}
const int N = 405, INF = 0x3f3f3f3f;
int n, head[N * 2], tail = 1, pre[2 * N];
struct EDGE {
  int to, next, flow;
  double cost;
  EDGE(int _t, int _n, int _f, double _c)
      : to(_t), next(_n), flow(_f), cost(_c) {}
  EDGE() : to(0), next(0), flow(0), cost(0) {}
} edge[N * N + 2 * N];
double x[N], y[N], dis[N * 2];
bool inq[N * 2];
inline void AddEdge(int u, int v, int flow, double cost) {
  edge[++tail] = EDGE(v, head[u], flow, cost);
  head[u] = tail;
}
inline void Add(int u, int v, int flow, double cost) {
  AddEdge(u, v, flow, cost);
  AddEdge(v, u, 0, -cost);
}
inline double Dis(int u, int v) {
  return sqrt((x[u] - x[v]) * (x[u] - x[v]) + (y[u] - y[v]) * (y[u] - y[v]));
}
inline bool SPFA(int s, int t) {
  for (int i = 1; i <= 2 * n + 2; ++i) dis[i] = 2e9, inq[i] = 0, pre[i] = 0;
  dis[s] = 0;
  inq[s] = 1;
  queue<int> Q;
  Q.push(s);
  while (Q.size()) {
    register int now = Q.front();
    inq[now] = 0;
    Q.pop();
    for (register int i = head[now]; i; i = edge[i].next) {
      if (!edge[i].flow) continue;
      int to = edge[i].to;
      double len = edge[i].cost;
      if (dis[to] > dis[now] + len) {
        pre[to] = i;
        dis[to] = dis[now] + len;
        if (!inq[to]) {
          Q.push(to);
          inq[to] = 1;
        }
      }
    }
  }
  return dis[t] != 2e9;
}
void MCMF(int s, int t) {
  double ans = 0;
  int mxF = 0;
  while (SPFA(s, t)) {
    int go = INF;
    for (int now = t; pre[now]; now = edge[pre[now] ^ 1].to)
      go = min(edge[pre[now]].flow, go);
    double sum = 0;
    for (int now = t; pre[now]; now = edge[pre[now] ^ 1].to)
      sum += edge[pre[now]].cost, edge[pre[now]].flow -= go,
          edge[pre[now] ^ 1].flow += go;
    ans += sum * go;
    mxF += go;
  }
  if (mxF < n - 1)
    printf("-1\n");
  else
    printf("%.10lf\n", ans);
}
int main() {
  n = Rd();
  for (int i = 1; i <= n; ++i) x[i] = Rd(), y[i] = Rd();
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      if (i != j && y[i] > y[j]) Add(i, j + n, 1, Dis(i, j));
  int s = 2 * n + 1, t = 2 * n + 2;
  for (int i = 1; i <= n; ++i) {
    Add(s, i, 2, 0);
    Add(i + n, t, 1, 0);
  }
  MCMF(s, t);
  return 0;
}