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 st, en, cap, flow, next;
  double cost;
  Edge() {}
  Edge(int a, int b, int c, double d, int e) {
    st = a, en = b, cap = c, cost = d, next = e, flow = 0;
  }
} edge[1000000];
int head[900], tot, now[900], pre[900];
int source, sink, FLOW, n;
double dis[900];
queue<int> q;
bool vs[900];
struct data {
  double x, y;
  bool operator<(const data &a) const {
    if (y == a.y)
      return x < a.x;
    else
      return y > a.y;
  }
} vertex[900];
void add_edge(int st, int en, int cap, double cost) {
  edge[tot] = Edge(st, en, cap, cost, head[st]);
  head[st] = tot++;
  edge[tot] = Edge(en, st, 0, -cost, head[en]);
  head[en] = tot++;
}
bool SPFA() {
  for (int i = source; i <= sink; i++)
    dis[i] = 0x3fffffff, vs[i] = false, now[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].en] > dis[u] + edge[i].cost) {
        dis[v] = dis[u] + edge[i].cost, now[v] = i;
        if (!vs[v]) vs[v] = 1, q.push(v);
      }
  }
  if (dis[sink] != 0x3fffffff)
    return true;
  else
    return false;
}
double MCMF() {
  double cost = 0;
  FLOW = 0;
  while (SPFA()) {
    int flow = 0x3fffffff;
    for (int u = sink; u != source; u = edge[now[u]].st)
      if (flow > edge[now[u]].cap - edge[now[u]].flow)
        flow = edge[now[u]].cap - edge[now[u]].flow;
    for (int u = sink; u != source; u = edge[now[u]].st) {
      edge[now[u]].flow += flow;
      edge[now[u] ^ 1].flow -= flow;
    }
    cost += flow * dis[sink];
    FLOW += flow;
  }
  return cost;
}
double cal_dis(int a, int b) {
  return sqrt((vertex[a].x - vertex[b].x) * (vertex[a].x - vertex[b].x) +
              (vertex[a].y - vertex[b].y) * (vertex[a].y - vertex[b].y));
}
void build(int n) {
  tot = 0, source = 0, sink = n + n + 1;
  for (int i = source; i <= sink; i++) head[i] = -1;
  for (int i = 1; i <= n; i++)
    add_edge(source, i, 2, 0), add_edge(i + n, sink, 1, 0);
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) {
      if (vertex[i].y == vertex[j].y) continue;
      add_edge(i, j + n, 1, cal_dis(i, j));
    }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lf%lf", &vertex[i].x, &vertex[i].y);
  sort(vertex + 1, vertex + n + 1);
  build(n);
  double ans = MCMF();
  if (FLOW != n - 1)
    printf("-1\n");
  else
    printf("%lf\n", ans);
  return 0;
}