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 maxedge = 1000000;
const int maxnode = 1000;
const int inf = 0x3f3f3f3f;
struct Edge {
  int st, ed, cap, flow, next;
  double cost;
  Edge() {}
  Edge(int a, int b, int c, double d, int e) {
    st = a, ed = b, cap = c, cost = d, next = e, flow = 0;
  }
} edge[maxedge];
int n;
struct Mcmf {
  int head[maxnode], index;
  int path[maxnode];
  int source, sink, FLOW;
  double dis[maxnode];
  bool vs[maxnode];
  queue<int> q;
  void init() {
    index = 0;
    source = 0;
    sink = n + n + 1;
    memset(head, -1, sizeof(head));
  }
  void addedge1(int st, int ed, int cap, double cost) {
    edge[index] = Edge(st, ed, cap, cost, head[st]);
    head[st] = index++;
    edge[index] = Edge(ed, st, 0, -cost, head[ed]);
    head[ed] = index++;
  }
  void addedge2(int st, int ed, int cap, double cost) {
    edge[index] = Edge(st, ed, cap, cost, head[st]);
    head[st] = index++;
    edge[index] = Edge(ed, st, cap, cost, head[ed]);
    head[ed] = index++;
  }
  bool spfa() {
    for (int i = source; i <= sink; i++)
      dis[i] = inf, vs[i] = false, path[i] = -1;
    while (!q.empty()) q.pop();
    q.push(source), dis[source] = 0, vs[source] = true;
    while (!q.empty()) {
      int u = q.front();
      q.pop(), vs[u] = 0;
      for (int i = head[u], v; i != -1; i = edge[i].next)
        if (edge[i].cap - edge[i].flow > 0 &&
            dis[v = edge[i].ed] > dis[u] + edge[i].cost) {
          dis[v] = dis[u] + edge[i].cost, path[v] = i;
          if (!vs[v]) vs[v] = 1, q.push(v);
        }
    }
    if (dis[sink] != inf)
      return true;
    else
      return false;
  }
  double mcmf() {
    double cost = 0;
    FLOW = 0;
    while (spfa()) {
      int flow = inf;
      for (int u = sink; u != source; u = edge[path[u]].st) {
        if (flow > edge[path[u]].cap - edge[path[u]].flow)
          flow = edge[path[u]].cap - edge[path[u]].flow;
      }
      for (int u = sink; u != source; u = edge[path[u]].st) {
        edge[path[u]].flow += flow;
        edge[path[u] ^ 1].flow -= flow;
      }
      cost += flow * dis[sink];
      FLOW += flow;
    }
    return cost;
  }
} MCMF;
struct data {
  double x, y;
} vertex[maxnode];
double caldis(int a, int b) {
  double rr = (vertex[a].x - vertex[b].x);
  double yy = (vertex[a].y - vertex[b].y);
  return sqrt(rr * rr + yy * yy);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lf%lf", &vertex[i].x, &vertex[i].y);
  MCMF.init();
  for (int i = 1; i <= n; i++) {
    MCMF.addedge1(MCMF.source, i, 2, 0);
    MCMF.addedge1(i + n, MCMF.sink, 1, 0);
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      if (vertex[i].y <= vertex[j].y) continue;
      MCMF.addedge1(i, j + n, 1, caldis(i, j));
    }
  double ans = MCMF.mcmf();
  if (MCMF.FLOW != n - 1)
    printf("-1\n");
  else
    printf("%lf\n", ans);
}