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 = 400;
const double INF = 1e10;
const double EPS = 1e-9;
const int V = N * 2 + 2;
const int MAXE = V * V;
struct Edge {
  int cap, nxt, to;
  double cost;
};
class minCostMaxFlow {
 public:
  Edge E[MAXE];
  int edges, head[V], bak[V], bake[V];
  double dis[V];
  bool vis[V];
  void init() {
    edges = 0;
    memset(head, -1, sizeof(head));
  }
  void add_edge(int u, int v, double w, int c) {
    E[edges] = (Edge){c, head[u], v, w};
    E[edges + 1] = (Edge){0, head[v], u, -w};
    head[u] = edges;
    head[v] = edges + 1;
    edges += 2;
  }
  double sol(int source, int target) {
    double answer = 0;
    while (true) {
      for (int i = 0; i <= target; ++i) {
        vis[i] = 0, dis[i] = INF;
      }
      queue<int> q;
      vis[source] = 1;
      dis[source] = 0;
      q.push(source);
      memset(bak, -1, sizeof(bak));
      memset(bake, -1, sizeof(bake));
      while (!q.empty()) {
        int u = q.front();
        q.pop();
        vis[u] = 0;
        for (int i = head[u]; i != -1;) {
          Edge &e = E[i];
          int v = e.to;
          if (e.cap > 0 && dis[u] + e.cost + EPS < dis[v]) {
            dis[v] = dis[u] + e.cost;
            bak[v] = u;
            bake[v] = i;
            if (!vis[v]) {
              vis[v] = 1;
              q.push(v);
            }
          }
          i = e.nxt;
        }
      }
      if (bak[target] == -1) break;
      answer += dis[target];
      for (int i = target; i != source; i = bak[i]) {
        E[bake[i]].cap -= 1;
        E[bake[i] ^ 1].cap += 1;
      }
    }
    return answer;
  }
  bool check(int n, int root, int target) {
    for (int i = 0; i < n; ++i)
      if (i != root) {
        int u = i + n;
        for (int j = head[u]; j != -1;) {
          Edge &e = E[j];
          if (e.to == target) {
            if (e.cap > 0) return 0;
          }
          j = e.nxt;
        }
      }
    return 1;
  }
};
int n, x[N], y[N];
minCostMaxFlow sol;
double dist(int u, int v) {
  double dx = x[u] - x[v], dy = y[u] - y[v];
  return sqrt(dx * dx + dy * dy);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", x + i, y + i);
  }
  int root_id = max_element(y, y + n) - y;
  int source = n << 1, target = n << 1 | 1;
  sol.init();
  for (int i = 0; i < n; ++i) {
    sol.add_edge(source, i, 0, 2);
    sol.add_edge(i + n, target, 0, 1);
  }
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      if (y[i] > y[j]) {
        sol.add_edge(i, j + n, dist(i, j), 1);
      }
  double answer = sol.sol(source, target);
  if (!sol.check(n, root_id, target)) {
    printf("-1");
    return 0;
  }
  printf("%.10f", answer);
  return 0;
}