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 N = 2e5 + 5;
double inf = 1e12;
int n, k;
struct graph {
  struct edge {
    int src, dst;
    int capacity, flow;
    double cost;
    size_t rev;
  };
  vector<edge> edges;
  void add_edge(int src, int dst, int cap, double cost) {
    adj[src].push_back({src, dst, cap, 0, cost, adj[dst].size()});
    adj[dst].push_back({dst, src, 0, 0, -cost, adj[src].size() - 1});
  }
  int n;
  vector<vector<edge>> adj;
  graph(int n) : n(n), adj(n) {}
  pair<int, double> min_cost_max_flow(int s, int t, int k) {
    int flow = 0;
    double cost = 0;
    for (int u = 0; u < n; ++u)
      for (auto &e : adj[u]) e.flow = 0;
    vector<double> p(n, 0);
    auto rcost = [&](edge e) { return e.cost + p[e.src] - p[e.dst]; };
    for (int iter = 0;; ++iter) {
      vector<int> prev(n, -1);
      prev[s] = 0;
      vector<double> dist(n, inf);
      dist[s] = 0;
      if (iter == 0) {
        vector<int> count(n);
        count[s] = 1;
        queue<int> que;
        for (que.push(s); !que.empty();) {
          int u = que.front();
          que.pop();
          count[u] = -count[u];
          for (auto &e : adj[u]) {
            if (e.capacity > e.flow && dist[e.dst] > dist[e.src] + rcost(e)) {
              dist[e.dst] = dist[e.src] + rcost(e);
              prev[e.dst] = e.rev;
              if (count[e.dst] <= 0) {
                count[e.dst] = -count[e.dst] + 1;
                que.push(e.dst);
              }
            }
          }
        }
      } else {
        priority_queue<pair<double, int>, vector<pair<double, int>>,
                       greater<pair<double, int>>>
            que;
        que.push({0, s});
        while (!que.empty()) {
          pair<double, int> a = que.top();
          que.pop();
          if (a.second == t) break;
          if (dist[a.second] > a.first) continue;
          for (auto e : adj[a.second]) {
            if (e.capacity > e.flow && dist[e.dst] > a.first + rcost(e)) {
              dist[e.dst] = dist[e.src] + rcost(e);
              prev[e.dst] = e.rev;
              que.push({dist[e.dst], e.dst});
            }
          }
        }
      }
      if (prev[t] == -1) break;
      for (int u = 0; u < n; ++u)
        if (dist[u] < dist[t]) p[u] += dist[u] - dist[t];
      function<int(int, int)> augment = [&](int u, int cur) {
        if (u == s) return cur;
        edge &r = adj[u][prev[u]], &e = adj[r.dst][r.rev];
        int f = augment(e.src, min(e.capacity - e.flow, cur));
        e.flow += f;
        r.flow -= f;
        return f;
      };
      int f = augment(t, k - flow);
      flow += f;
      cost += f * (p[t] - p[s]);
      if (flow == k) break;
    }
    return {flow, cost};
  }
};
pair<double, double> p[N];
inline double dist(int a, int b) {
  return sqrt((p[a].first - p[b].first) * (p[a].first - p[b].first) +
              (p[a].second - p[b].second) * (p[a].second - p[b].second));
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int i, j, a = 0, b = 0;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> p[i].second >> p[i].first;
  sort(p + 1, p + n + 1);
  reverse(p + 1, p + n + 1);
  graph g(2 * n + 5);
  for (i = 1; i <= n; i++)
    g.add_edge(0, 2 * i - 1, 2, 0), g.add_edge(2 * i, 2 * n + 1, 1, 0);
  for (i = 2; i <= n; i++) {
    for (j = 1; j < i; j++)
      if (p[j].first > p[i].first) g.add_edge(j * 2 - 1, i * 2, 1, dist(i, j));
  }
  pair<int, double> it = g.min_cost_max_flow(0, 2 * n + 1, n - 1);
  if (it.first == n - 1)
    cout << setprecision(10) << it.second;
  else
    cout << -1;
}