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;
template <typename T>
T in() {
  char ch;
  T n = 0;
  bool ng = false;
  while (1) {
    ch = getchar();
    if (ch == '-') {
      ng = true;
      ch = getchar();
      break;
    }
    if (ch >= '0' && ch <= '9') break;
  }
  while (1) {
    n = n * 10 + (ch - '0');
    ch = getchar();
    if (ch < '0' || ch > '9') break;
  }
  return (ng ? -n : n);
}
template <typename T>
inline T POW(T B, T P) {
  if (P == 0) return 1;
  if (P & 1)
    return B * POW(B, P - 1);
  else
    return (POW(B, P / 2) * POW(B, P / 2));
}
template <typename T>
inline T Gcd(T a, T b) {
  if (a < 0) return Gcd(-a, b);
  if (b < 0) return Gcd(a, -b);
  return (b == 0) ? a : Gcd(b, a % b);
}
template <typename T>
inline T Lcm(T a, T b) {
  if (a < 0) return Lcm(-a, b);
  if (b < 0) return Lcm(a, -b);
  return a * (b / Gcd(a, b));
}
long long Bigmod(long long base, long long power, long long MOD) {
  long long ret = 1;
  while (power) {
    if (power & 1) ret = (ret * base) % MOD;
    base = (base * base) % MOD;
    power >>= 1;
  }
  return ret;
}
bool isVowel(char ch) {
  ch = toupper(ch);
  if (ch == 'A' || ch == 'U' || ch == 'I' || ch == 'O' || ch == 'E')
    return true;
  return false;
}
template <typename T>
long long int isLeft(T a, T b, T c) {
  return (a.x - b.x) * (b.y - c.y) - (b.x - c.x) * (a.y - b.y);
}
long long ModInverse(long long number, long long MOD) {
  return Bigmod(number, MOD - 2, MOD);
}
bool isConst(char ch) {
  if (isalpha(ch) && !isVowel(ch)) return true;
  return false;
}
int toInt(string s) {
  int sm;
  stringstream second(s);
  second >> sm;
  return sm;
}
int head[802 + 10], par[802 + 10];
double dis[802 + 10];
bool chk[802 + 10];
struct Edge {
  int u, v, cap, next;
  double cost;
  Edge() {}
  Edge(int a, int b, int c, double d, int e) {
    u = a, v = b, cap = c, cost = d, next = e;
  }
};
Edge edge[2 * 802 * 802];
int NE;
void init(int n) {
  for (int i = 0; i <= n; i++) head[i] = -1;
  NE = 0;
}
void addEdge(int u, int v, int cap, double cost) {
  edge[NE] = Edge(u, v, cap, cost, head[u]);
  head[u] = NE++;
  edge[NE] = Edge(v, u, 0, -cost, head[v]);
  head[v] = NE++;
}
int spfa(int src, int sink, int tot) {
  queue<int> Q;
  for (int i = 0; i <= tot; i++)
    par[i] = -1, chk[i] = false, dis[i] = 2000000000;
  Q.push(src);
  dis[src] = 0.0;
  chk[src] = true;
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    chk[u] = false;
    for (int i = head[u]; i != -1; i = edge[i].next) {
      int v = edge[i].v;
      double w = edge[i].cost;
      if (edge[i].cap > 0 && dis[v] > dis[u] + w) {
        dis[v] = dis[u] + w;
        par[v] = i;
        if (!chk[v]) {
          chk[v] = true;
          Q.push(v);
        }
      }
    }
  }
  if (par[sink] == -1) return 0;
  int cap = 2000000000;
  for (int i = par[sink]; i != -1; i = par[edge[i].u])
    cap = min(cap, edge[i].cap);
  for (int i = par[sink]; i != -1; i = par[edge[i].u])
    edge[i].cap -= cap, edge[i ^ 1].cap += cap;
  return cap;
}
pair<int, double> min_cost_flow(int src, int sink, int tot) {
  double ret = 0;
  int flow = 0;
  while (true) {
    int cap = spfa(src, sink, tot);
    if (cap == 0) break;
    flow += cap;
    ret += (cap * 1.0 * dis[sink]);
  }
  return make_pair(flow, ret);
}
pair<int, int> a[802];
double Dist(int i, int j) {
  double x = (a[i].first - a[j].first) * (a[i].first - a[j].first);
  x += (a[i].second - a[j].second) * (a[i].second - a[j].second);
  x = sqrt(x);
  return x;
}
int main() {
  int n;
  n = in<int>();
  for (int i = 1; i < n + 1; i++) {
    a[i].first = in<int>(), a[i].second = in<int>();
  }
  init(n * 2 + 4);
  int src = 0, des = (n * 2) + 1;
  for (int i = 1; i < n + 1; i++) {
    addEdge(0, i, 2, 0);
    addEdge(i + n, des, 1, 0);
  }
  for (int i = 1; i < n + 1; i++) {
    for (int j = 1; j < n + 1; j++) {
      if (a[i].second > a[j].second) {
        double dst = Dist(i, j);
        addEdge(i, j + n, 1, dst);
      }
    }
  }
  pair<int, double> ans = min_cost_flow(src, des, des);
  if (ans.first != (n - 1)) {
    printf("-1\n");
  } else {
    printf("%.10lf\n", ans.second);
  }
  return 0;
}