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
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <cfloat>

using namespace std;

const double EPS = 1e-8;

int dcmp(double d) {
    if (fabs(d) < EPS) {
        return 0;
    }
    else {
        return d < 0? -1 : 1;
    }
}

struct Vector {
    double x, y;
    Vector(double x = 0, double  y = 0):x(x), y(y) {
    }
     
    bool operator<(const Vector& other) const {
        return dcmp(x - other.x) < 0 || (dcmp(x - other.x) == 0 && dcmp(y - other.y) < 0);
    }
};

typedef Vector Point;

double dist(const Point& a, const Point& b) {
    return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}

bool cmpY(const Point& a,  const Point& b) {
    return dcmp(a.y - b.y) < 0 || (dcmp(a.y - b.y) == 0 && dcmp(a.x - b.x) < 0);
}

double combine(vector<Point>& p, int l, int m, int r, double leftSmall, double rightSmall) {
    double d = min(leftSmall, rightSmall);
    double x = (p.at(m).x + p.at(m + 1).x)/2;
    
    vector<Point> strip;
        
    for (int i = m; i >= l && dcmp(x - p.at(i).x - d) <= 0; i--) {
        strip.push_back(p.at(i));
    }
    for (int j = m + 1; j <= r &&dcmp(p.at(j).x - x - d) <= 0; j++) {
        strip.push_back(p.at(j));
    } 
    
    sort(strip.begin(), strip.end(), cmpY);
    
    int size = strip.size();
    
    for (int i = 0; i < size; i++) {
        for (int j = i+1; j < size && dcmp(strip[j].y - strip[i].y - d) < 0; j++) {
            if (dcmp(dist(strip[i], strip[j]) - d) < 0) {
                d = dist(strip[i], strip[j]);
            }
        }
    }
    return d;
}

//naive n^2 method
double combine1(vector<Point>& p, int l, int m, int r, double leftSmall, double rightSmall) {
    double d = min(leftSmall, rightSmall);
    double x = (p.at(m).x + p.at(m + 1).x)/2;
    
    double best = DBL_MAX;
    
    for (int i = m; i >= l && dcmp(x - p.at(i).x - d) <= 0; i--) {
        for (int j = m + 1; j <= r &&dcmp(p.at(j).x - x - d) <= 0; j++) {
            best = min(best, dist(p.at(i), p.at(j)));
        } 
    }
    return min(best, d);
}


double solve(vector<Point>& p, int l, int r) {
    if (l >= r) {
        return DBL_MAX;
    }
    int m = (l + r) / 2;
    
    double leftSmall = solve(p, l, m);
    double rightSmall = solve(p, m + 1, r);
    
    return combine(p, l, m, r, leftSmall, rightSmall);
}

int main() {
    int n; 
    cin >> n;
    vector<Point> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i].x >> p[i].y;
    }
    
    sort(p.begin(), p.end());
    
    double ans = solve(p, 0, n - 1);
    
    cout << fixed << setprecision(8) << ans << endl;
    
    return 0;
}