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 <complex>
#include <cstdio>
#include <iostream>
#include <utility>
#include <vector>
#define X real()
#define Y imag()
#define EPS (1e-10)
#define INF (1e9)
using namespace std;
typedef complex<double> P;

namespace std{
  bool operator<(const P& a, const P& b){
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
  bool cmp_y(const P &a, const P &b){
    return a.Y != b.Y ? a.Y < b.Y : a.X < b.X;
  }
}

double closest_pair(P *a, int n){
  if(n <= 1) return INF;
  int m = n/2;
  double x = a[m].X;
  double d = min(closest_pair(a,m),closest_pair(a+m,n-m));
  inplace_merge(a,a+m,a+n,cmp_y);
  vector<P> b;
  for(int i = 0; i < n; ++i){
    if(abs(x-a[i].X) >= d) continue;
    for(int j = 0; j < b.size(); ++j){
      P dp = a[i] - b[b.size()-1-j];
      if(dp.Y >= d) break;
      d = min(d,abs(dp));
    }
    b.push_back(a[i]);
  }
  return d;
}

double compute_shortest(P *a, int n){
  sort(a, a+n);
  return closest_pair(a,n);
}

int main(){
  int n;
  cin >> n;
  double x, y;
  P p[n];
  for(int i = 0; i < n; ++i){
    cin >> x >> y;
    p[i] = P(x,y);
  }
  printf("%.10lf\n", compute_shortest(p,n));
  return 0;
}