Problem: For given n points in metric space, find the distance of the closest points.

Constraints

* 2 ≤ n ≤ 100,000
* -100 ≤ x, y ≤ 100

Input


n
x0 y0
x1 y1
:
xn-1 yn-1


The first integer n is the number of points.

In the following n lines, the coordinate of the i-th point is given by two real numbers xi and yi. Each value is a real number with at most 6 digits after the decimal point.

Output

Print the distance in a line. The output values should be in a decimal fraction with an error less than 0.000001.

Examples

Input

2
0.0 0.0
1.0 0.0


Output

1.000000


Input

3
0.0 0.0
2.0 0.0
1.0 1.0


Output

1.41421356237

Solution (in CPP):

Solution:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <float.h>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

struct Point {
  double y;
  double x;

  Point(double y = -1, double x = -1) {
    this->y = y;
    this->x = x;
  }
};

bool compareY(const Point &p1, const Point &p2) {
  return p1.y < p2.y;
}

bool compareX(const Point &p1, const Point &p2) {
  return p1.x < p2.x;
}

double closestPair(Point *points, int n) {
  if (n <= 1) return DBL_MAX;

  int m = n / 2;
  double x = points[m].x;
  double d = min(closestPair(points, m), closestPair(points + m, n - m));
  inplace_merge(points, points + m, points + n, compareY);

  vector<Point> b;
  for (int i = 0; i < n; ++i) {
    if (fabs(points[i].x - x) >= d) continue;

    for (int j = 0; j < b.size(); ++j) {
      double dx = points[i].x - b[b.size() - j - 1].x;
      double dy = points[i].y - b[b.size() - j - 1].y;

      if (dy >= d) break;
      d = min(d, sqrt(dx * dx + dy * dy));
    }
    b.push_back(points[i]);
  }

  return d;
}

int main() {
  int N;
  cin >> N;
  Point points[N];

  double x, y;
  for (int i = 0; i < N; ++i) {
    cin >> x >> y;
    points[i] = Point(y, x);
  }

  sort(points, points + N, compareX);

  cout << fixed << setprecision(10) << closestPair(points, N) << endl;

  return 0;
}