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 point {
  int x;
  int y;
  point() { x = y = 0; }
  point(int _x, int _y) {
    x = _x;
    y = _y;
  }
};
struct edge {
  int to;
  int inv;
  int cap;
  double cost;
  int flow;
  edge(int _t, int _inv, int _cap, double _cost) {
    to = _t;
    inv = _inv;
    cap = _cap;
    cost = _cost;
    flow = 0;
  }
  edge() {
    to = -1;
    cap = inv = cost = flow = 0;
  }
};
vector<point> coord;
vector<vector<edge>> graph(802);
vector<double> d(802);
vector<int> prevEdge(802);
vector<int> flag(802);
vector<double> phi(802, 0);
vector<int> used(802, 0);
double dist(point a, point b) {
  return (sqrt(double((b.x - a.x) * (b.x - a.x) + (b.y - a.y) * (b.y - a.y))));
}
struct myComparator {
  bool operator()(pair<int, int> a, pair<int, int> b) {
    return a.second < b.second;
  }
};
void Dijkstra(int n, int s) {
  fill(prevEdge.begin(), prevEdge.end(), 0);
  fill(d.begin(), d.end(), 10000000000);
  fill(used.begin(), used.end(), 0);
  d[s] = 0;
  prevEdge[s] = -1;
  priority_queue<pair<int, double>, vector<pair<int, double>>, myComparator> Q;
  Q.push(make_pair(s, 0));
  while (!Q.empty()) {
    pair<int, double> cur = Q.top();
    Q.pop();
    int w = cur.first;
    double wDist = cur.second;
    if (wDist > d[w]) continue;
    for (int i = 0; i < graph[w].size(); i++) {
      edge e = graph[w][i];
      if (e.cap > e.flow) {
        edge e = graph[w][i];
        int v = e.to;
        if (d[v] > wDist + e.cost + phi[w] - phi[v]) {
          d[v] = wDist + e.cost + phi[w] - phi[v];
          prevEdge[v] = graph[w][i].inv;
          Q.push(make_pair(v, d[v]));
        }
      }
    }
  }
}
void Dijkstra2(int n, int s) {
  fill(d.begin(), d.end(), 10000000000);
  fill(used.begin(), used.end(), 0);
  d[s] = 0;
  prevEdge[s] = -1;
  while (true) {
    int v = -1;
    for (int i = 0; i < 2 * n + 2; i++) {
      if (!used[i] && d[i] < 10000000000 && (v < 0 || d[v] > d[i])) v = i;
    }
    if (v < 0) break;
    used[v] = 1;
    for (int i = 0; i < graph[v].size(); i++) {
      if (graph[v][i].cap > graph[v][i].flow) {
        int e = graph[v][i].to;
        if (!used[e] && d[e] > d[v] + graph[v][i].cost + phi[v] - phi[e]) {
          d[e] = d[v] + graph[v][i].cost + phi[v] - phi[e];
          prevEdge[e] = graph[v][i].inv;
        }
      }
    }
  }
}
pair<int, double> minCostMaxFlow(int n, int s, int t) {
  int maxFlow = 0;
  double flowCost = 0;
  while (true) {
    Dijkstra2(n, s);
    if (d[t] >= 10000000000) break;
    for (int i = 0; i <= 2 * n + 1; i++) {
      phi[i] += d[i] < 10000000000 ? d[i] : d[t];
    }
    int curFlow = 10000000000;
    double curCost = 0;
    int i = t;
    while (i != s) {
      int w = graph[i][prevEdge[i]].to;
      int ed = graph[i][prevEdge[i]].inv;
      curFlow = min(curFlow, graph[w][ed].cap - graph[w][ed].flow);
      curCost += graph[w][ed].cost;
      i = w;
    }
    i = t;
    while (i != s) {
      int w = graph[i][prevEdge[i]].to;
      int ed = graph[i][prevEdge[i]].inv;
      graph[w][ed].flow += curFlow;
      graph[i][prevEdge[i]].flow -= curFlow;
      i = w;
    }
    maxFlow += curFlow;
    flowCost += curFlow * curCost;
  }
  return make_pair(maxFlow, flowCost);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    coord.push_back(point(x, y));
  }
  for (int i = 0; i < coord.size(); i++) {
    point a = coord[i];
    graph[0].push_back(edge(i + 1, graph[i + 1].size(), 2, 0));
    graph[i + 1].push_back(edge(0, graph[0].size() - 1, 0, 0));
    graph[i + n + 1].push_back(edge(2 * n + 1, graph[2 * n + 1].size(), 1, 0));
    graph[2 * n + 1].push_back(
        edge(i + n + 1, graph[i + n + 1].size() - 1, 0, 0));
    for (int j = 0; j < coord.size(); j++) {
      if (i != j) {
        point b = coord[j];
        if (a.y > b.y) {
          graph[i + 1].push_back(
              edge(j + n + 1, graph[j + n + 1].size(), 1, dist(a, b)));
          graph[j + n + 1].push_back(
              edge(i + 1, graph[i + 1].size() - 1, 0, -dist(a, b)));
        }
      }
    }
  }
  pair<int, double> result = minCostMaxFlow(n, 0, 2 * n + 1);
  if (result.first == n - 1) {
    printf("%.14f\n", result.second);
    return 0;
  }
  printf("%d\n", -1);
  return 0;
}