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;
struct Edge {
  int ed, flow, next;
  double cost;
} edge[1000010];
int head[1024], nEdge;
double dis[1024];
bool vis[1024];
int que[1024 * 1024 * 2], front, rear;
inline void init() {
  memset(head, -1, sizeof(head));
  nEdge = 0;
}
inline void addEdge(int a, int b, int f, double c) {
  edge[nEdge].ed = b;
  edge[nEdge].flow = f;
  edge[nEdge].cost = c;
  edge[nEdge].next = head[a];
  head[a] = nEdge++;
  edge[nEdge].ed = a;
  edge[nEdge].flow = 0;
  edge[nEdge].cost = -c;
  edge[nEdge].next = head[b];
  head[b] = nEdge++;
}
int dfs(int x, int dst, int pre) {
  int i, y, cur = pre, d;
  if (x == dst) return pre;
  for (vis[x] = true, i = head[x]; ~i; i = edge[i].next) {
    if (edge[i].flow && fabs(edge[i].cost) < 1e-8 && !vis[y = edge[i].ed]) {
      d = dfs(y, dst, min(cur, edge[i].flow));
      edge[i].flow -= d;
      edge[i ^ 1].flow += d;
      if (!(cur -= d)) break;
    }
  }
  if (!cur) vis[x] = false;
  return pre - cur;
}
bool spfa(int v, int src, int dst) {
  int i, x, y;
  fill(dis, dis + v, 1e10);
  memset(vis, 0, sizeof(vis));
  front = rear = v;
  dis[src] = 0;
  vis[que[rear++] = src] = true;
  while (front < rear) {
    vis[x = que[front++]] = false;
    for (i = head[x]; ~i; i = edge[i].next) {
      if (edge[i].flow && dis[y = edge[i].ed] > dis[x] + edge[i].cost) {
        dis[y] = dis[x] + edge[i].cost;
        if (!vis[y]) vis[que[rear++] = y] = true;
      }
    }
  }
  return dis[dst] < 1000000000;
}
int minCostMaxFlow(int v, int src, int dst, double &netCost) {
  int i, x, curFlow, totalFlow = 0;
  double d = 0;
  for (netCost = 0; spfa(v, src, dst);) {
    d += dis[dst];
    for (x = 0; x < v; ++x) {
      for (i = head[x]; ~i; i = edge[i].next) {
        edge[i].cost += dis[x] - dis[edge[i].ed];
      }
    }
    memset(vis, 0, sizeof(vis));
    curFlow = dfs(src, dst, 1000000000);
    totalFlow += curFlow;
    netCost += d * curFlow;
  }
  return totalFlow;
}
struct Point {
  double x, y;
  Point() {}
  Point(double _x, double _y) : x(_x), y(_y) {}
} p[1024];
inline double dist(const Point &a, const Point &b) {
  return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
int main() {
  int n, v, src, dst, i, j;
  double ans;
  while (~scanf("%d", &n)) {
    init();
    for (i = 0; i < n; ++i) scanf("%lf %lf", &p[i].x, &p[i].y);
    v = 2 * n + 2;
    src = 2 * n;
    dst = 2 * n + 1;
    for (i = 0; i < n; ++i) {
      addEdge(src, ((i) << 1), 2, 0);
      addEdge((((i) << 1) | 1), dst, 1, 0);
      for (j = 0; j < n; ++j) {
        if (p[i].y > p[j].y)
          addEdge(((i) << 1), (((j) << 1) | 1), 1, dist(p[i], p[j]));
      }
    }
    if (minCostMaxFlow(v, src, dst, ans) == n - 1) {
      printf("%.8lf\n", ans);
    } else {
      printf("-1\n");
    }
  }
  return 0;
}