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 dy[] = {-1, 0, 1, 0}, dx[] = {0, 1, 0, -1};
const double EPS = 1e-5;
const double PI = acos(-1.0);
int popcount(int n) { return __builtin_popcount(n); }
int popcount(unsigned long long n) { return __builtin_popcountll(n); }
template <class T>
int SIZE(T a) {
  return a.size();
}
template <class T>
string IntToString(T num) {
  string res;
  stringstream ss;
  ss << num;
  return ss.str();
}
template <class T>
T StringToInt(string str) {
  T res = 0;
  for (int i = 0; i < SIZE(str); i++) res = (res * 10 + str[i] - '0');
  return res;
}
template <class T>
T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
void PrintSeq(T &a, int sz) {
  for (int i = 0; i < sz; i++) {
    cout << a[i];
    if (sz == i + 1)
      cout << endl;
    else
      cout << ' ';
  }
}
bool EQ(double a, double b) { return abs(a - b) < EPS; }
bool EQV(complex<double> a, complex<double> b) {
  return EQ(a.real(), b.real()) & EQ(a.imag(), b.imag());
}
void fastStream() {
  cin.tie(0);
  std::ios_base::sync_with_stdio(0);
}
vector<string> split(string str, char del) {
  vector<string> res;
  for (int i = 0, s = 0; i < SIZE(str); i++) {
    if (str[i] == del) {
      if (i - s != 0) res.push_back(str.substr(s, i - s));
      s = i + 1;
    } else if (i == SIZE(str) - 1) {
      res.push_back(str.substr(s));
    }
  }
  return res;
}
class MinCostFlow {
 private:
  static const int MAX_V = 10000;
  struct edge {
    int to, cap, rev;
    double cost;
  };
  vector<edge> G[MAX_V];
  double dist[MAX_V];
  double h[MAX_V];
  int prevv[MAX_V];
  int preve[MAX_V];

 public:
  void add_edge(int from, int to, int cap, double cost) {
    edge e;
    e.to = to, e.cap = cap, e.cost = cost, e.rev = G[to].size();
    G[from].push_back(e);
    e.to = from, e.cap = 0, e.cost = -cost, e.rev = G[from].size() - 1;
    G[to].push_back(e);
  }
  void clearGraph() {
    for (int i = 0; i < MAX_V; i++) G[i].clear();
  }
  double min_cost_flow(int s, int t, int f, int V) {
    const int INF = 1000000000;
    double res = 0;
    fill(h, h + V, 0);
    while (f > 0) {
      priority_queue<pair<double, int>, vector<pair<double, int> >,
                     greater<pair<double, int> > >
          que;
      fill(dist, dist + V, INF);
      dist[s] = 0;
      que.push(pair<double, int>(0, s));
      while (!que.empty()) {
        pair<double, int> p = que.top();
        que.pop();
        int v = p.second;
        if (dist[v] < p.first) continue;
        for (int i = 0; i < (int)G[v].size(); i++) {
          edge &e = G[v][i];
          if (e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]) {
            dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
            prevv[e.to] = v;
            preve[e.to] = i;
            que.push(pair<double, int>(dist[e.to], e.to));
          }
        }
      }
      if (EQ(dist[t], INF)) return -1;
      for (int i = 0; i < V; i++) h[i] += dist[i];
      int d = f;
      for (int v = t; v != s; v = prevv[v])
        d = min(d, G[prevv[v]][preve[v]].cap);
      f -= d;
      res += d * h[t];
      for (int v = t; v != s; v = prevv[v]) {
        edge &e = G[prevv[v]][preve[v]];
        e.cap -= d;
        G[v][e.rev].cap += d;
      }
    }
    return res;
  }
};
int N;
int XS[401], YS[401];
double getDist(int a, int b) {
  return sqrt(1.0 * (XS[a] - XS[b]) * (XS[a] - XS[b]) +
              (YS[a] - YS[b]) * (YS[a] - YS[b]));
}
MinCostFlow mf;
int main() {
  cin >> N;
  int maxy = -1;
  for (int i = 0; i < N; i++) {
    cin >> XS[i] >> YS[i];
    maxy = max(YS[i], maxy);
  }
  int cnt = 0;
  for (int i = 0; i < N; i++)
    if (maxy == YS[i]) cnt++;
  if (cnt > 1)
    cout << -1 << endl;
  else {
    mf.clearGraph();
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (YS[i] > YS[j]) mf.add_edge(i, j + N, 1, getDist(i, j));
      }
    }
    const int st = 2 * N;
    const int gl = 2 * N + 1;
    for (int i = 0; i < N; i++)
      mf.add_edge(st, i, 2, 0), mf.add_edge(i + N, gl, 1, 0);
    double sumDist = mf.min_cost_flow(st, gl, N - 1, 2 * N + 2);
    if (sumDist < 0)
      cout << -1 << endl;
    else
      printf("%.10f\n", sumDist);
  }
  return 0;
}