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 Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const long long INF = 99999999;
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 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, INF);
      flow += f;
      cost += f * (p[t] - p[s]);
    }
    return {flow, cost};
  }
};
long long x[500], y[500];
inline double dist(long long x1, long long y1, long long x2, long long y2) {
  double ans = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
  ans = sqrt(ans);
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << setprecision(25);
  long long n;
  cin >> n;
  graph g(2 * n + 2);
  long long s = 0;
  long long t = 2 * n + 1;
  for (long long i = 1; i <= n; i++) {
    cin >> x[i] >> y[i];
    g.add_edge(s, i, 2, 0);
    g.add_edge(i + n, t, 1, 0);
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= n; j++) {
      if (y[j] >= y[i]) continue;
      g.add_edge(i, j + n, 1, dist(x[i], y[i], x[j], y[j]));
    }
  }
  long long mf;
  double mc;
  tie(mf, mc) = g.min_cost_max_flow(s, t);
  if (mf != n - 1)
    cout << "-1\n";
  else
    cout << mc << '\n';
}