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;
namespace MCF {
struct edge {
  int dest;
  int cap, flow;
  double cost;
  int next;
  edge() {}
  edge(int dest, int cap, double cost, int next)
      : dest(dest), cap(cap), cost(cost), next(next) {
    flow = 0;
  }
};
const int MAXV = 2005;
const int MAXE = 1000000;
int nodes, source, sink;
int size;
edge g[MAXE];
int first[MAXV];
int nLast[MAXV];
int eLast[MAXV];
double cst[MAXV];
void initialize(int __nodes, int __source, int __sink) {
  size = 0;
  nodes = __nodes;
  source = __source;
  sink = __sink;
  for (int i = 0; i < nodes; i++) first[i] = -1;
}
void addEdge(int u, int v, int c, double cost) {
  g[size] = edge(v, c, +cost, first[u]);
  first[u] = size++;
  g[size] = edge(u, 0, -cost, first[v]);
  first[v] = size++;
}
pair<double, double> maxFlowMinCost() {
  int flow = 0;
  double flowCost = 0;
  while (true) {
    priority_queue<pair<double, double> > Q;
    for (int i = 0; i < nodes; i++) cst[i] = 1 << 29;
    cst[source] = 0;
    Q.push(make_pair(0, source));
    while (!Q.empty()) {
      int u = Q.top().second;
      double c = -Q.top().first;
      Q.pop();
      if (u == sink) break;
      for (int k = first[u]; k != -1; k = g[k].next) {
        int newU = g[k].dest;
        double newC = g[k].cost + c;
        if (g[k].cap > g[k].flow && newC < cst[newU]) {
          cst[newU] = newC;
          nLast[newU] = u;
          eLast[newU] = k;
          Q.push(make_pair(-newC, newU));
        }
      }
    }
    if (cst[sink] == 1 << 29) break;
    int push = 1 << 29;
    for (int u = sink; u != source; u = nLast[u])
      push = min(push, g[eLast[u]].cap - g[eLast[u]].flow);
    flow += push;
    flowCost += cst[sink] * push;
    for (int u = sink; u != source; u = nLast[u]) {
      g[eLast[u]].flow += push;
      g[eLast[u] ^ 1].flow -= push;
    }
  }
  return make_pair(flow, flowCost);
}
};  // namespace MCF
const int MAXN = 2500;
int n;
complex<int> points[MAXN];
double sqr(double x) { return x * x; }
double dist(complex<int> a, complex<int> b) {
  return sqrt(sqr(a.real() - b.real()) + sqr(a.imag() - b.imag()));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  MCF::initialize(2 * n + 2, 0, 2 * n + 1);
  int x1, y1;
  for (int i = 1; i <= n; i++) {
    MCF::addEdge(0, i, 1, 0);
    MCF::addEdge(n + i, 2 * n + 1, 2, 0);
    cin >> x1 >> y1;
    points[i] = complex<int>(x1, y1);
    for (int j = 1; j < i; j++) {
      if (points[i].imag() == points[j].imag()) continue;
      if (points[i].imag() < points[j].imag())
        MCF::addEdge(i, j + n, 1, dist(points[i], points[j]));
      else
        MCF::addEdge(j, i + n, 1, dist(points[i], points[j]));
    }
  }
  cout << setprecision(15);
  pair<double, double> sol = MCF::maxFlowMinCost();
  if (sol.first != n - 1)
    cout << -1 << "\n";
  else
    cout << fixed << sol.second << "\n";
  return 0;
}