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 <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

#define INF 1000000000.0;
typedef pair<double, double> P;


bool compare_y(P a, P b){
    return a.second < b.second;
}

double closest_pair(vector<P> &a, int pos, int n){
    if(n==1) return INF;
    int m = n/2;
    double x = a[m+pos].first;
    double d = min(closest_pair(a,pos,m), closest_pair(a,pos+m,n-m));
    inplace_merge(a.begin()+pos,a.begin()+pos+m,a.begin()+pos+n, compare_y);

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

        for(int j=0;j < b.size(); j++){
            double dx = a[i+pos].first - b[b.size()-1-j].first;
            double dy = a[i+pos].second - b[b.size()-j-1].second;
            if(dy >= d) break;
            d = min(d, sqrt(dx *dx + dy * dy));
        }
        b.push_back(a[i+pos]);
    }
    /*
    for(int i=0;i<n;i++){
        cout << "(" << a[i+pos].first <<","<< a[i+pos].second<<")";
    }
    cout << endl;
    cout << d << endl;
    */
    return d;
}

int main(){
    int n; cin >> n;
    vector<P> points(n);
    for(int i=0;i<n;i++){
        cin >> points[i].first >> points[i].second;
    }
    sort(points.begin(), points.end());
    printf("%.16lf\n", closest_pair(points, 0, n));
}