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 maxn = 1005;
int n;
const double eps = 1e-10;
int dcmp(double x) {
  if (fabs(x) < eps) return 0;
  return (x > eps) - (x < -eps);
}
struct Point {
  double x, y;
  Point(double x = 0, double y = 0) : x(x), y(y) {}
} P[maxn];
bool operator<(const Point& a, const Point& b) {
  return dcmp(a.x - b.x) < 0 || (dcmp(a.x - b.x) == 0 && dcmp(a.y - b.y) < 0);
}
Point operator+(const Point& A, const Point& B) {
  return Point(A.x + B.x, A.y + B.y);
}
Point operator-(const Point& A, const Point& B) {
  return Point(A.x - B.x, A.y - B.y);
}
Point operator*(const Point& A, double p) { return Point(A.x * p, A.y * p); }
Point operator/(const Point& A, double p) { return Point(A.x / p, A.y / p); }
bool operator==(const Point& a, const Point& b) {
  return dcmp(a.x - b.x) == 0 && dcmp(a.y - b.y) == 0;
}
double Dot(const Point& A, const Point& B) { return A.x * B.x + A.y * B.y; }
double Length(const Point& A) { return sqrt(Dot(A, A)); }
const double INF = 1 << 30;
struct Edge {
  int from, to, cap, flow;
  double cost;
  Edge(int from = 0, int to = 0, int cap = 0, int flow = 0, double cost = 0.0)
      : from(from), to(to), cap(cap), flow(flow), cost(cost) {}
};
struct MCMF {
  int n, m, s, t;
  vector<Edge> edges;
  vector<int> G[maxn];
  int inq[maxn];
  double d[maxn];
  int p[maxn];
  int a[maxn];
  void init(int n) {
    this->n = n;
    for (int i = 0; i < n; i++) G[i].clear();
    edges.clear();
  }
  void AddEdge(int from, int to, int cap, double cost) {
    edges.push_back((Edge){from, to, cap, 0, cost});
    edges.push_back((Edge){to, from, 0, 0, -cost});
    m = edges.size();
    G[from].push_back(m - 2);
    G[to].push_back(m - 1);
  }
  bool BellmanFord(int s, int t, int& flow, double& cost) {
    for (int i = 0; i < n; i++) d[i] = INF;
    memset(inq, 0, sizeof(inq));
    d[s] = 0;
    inq[s] = 1;
    p[s] = 0;
    a[s] = INF;
    queue<int> Q;
    Q.push(s);
    while (!Q.empty()) {
      int u = Q.front();
      Q.pop();
      inq[u] = 0;
      for (int i = 0; i < G[u].size(); i++) {
        Edge& e = edges[G[u][i]];
        if (e.cap > e.flow && d[e.to] > d[u] + e.cost) {
          d[e.to] = d[u] + e.cost;
          p[e.to] = G[u][i];
          a[e.to] = min(a[u], e.cap - e.flow);
          if (!inq[e.to]) {
            Q.push(e.to);
            inq[e.to] = 1;
          }
        }
      }
    }
    if (dcmp(d[t] - INF) == 0) return false;
    flow += a[t];
    cost += d[t] * a[t];
    int u = t;
    while (u != s) {
      edges[p[u]].flow += a[t];
      edges[p[u] ^ 1].flow -= a[t];
      u = edges[p[u]].from;
    }
    return true;
  }
  void Mincost(int s, int t) {
    int flow = 0;
    double cost = 0;
    while (BellmanFord(s, t, flow, cost))
      ;
    if (flow + 1 < (n - 2) / 2)
      printf("-1\n");
    else
      printf("%.15f\n", cost);
  }
} solver;
int main() {
  while (scanf("%d", &n) == 1) {
    for (int i = 1; i <= n; i++) {
      double x, y;
      scanf("%lf%lf", &x, &y);
      P[i] = Point(x, y);
    }
    sort(P + 1, P + 1 + n);
    int S = 0, T = 2 * n + 1;
    solver.init(2 * n + 2);
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++)
        if (dcmp(P[i].y - P[j].y) > 0)
          solver.AddEdge(i, n + j, 1, Length(P[i] - P[j]));
    for (int i = 1; i <= n; i++) {
      solver.AddEdge(S, i, 2, 0);
      solver.AddEdge(n + i, T, 1, 0);
    }
    solver.Mincost(S, T);
  }
  return 0;
}