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 <bits/stdc++.h>

using namespace std;

struct Point {
    double x, y;
    Point(double x, double y) : x(x), y(y) {}
    Point() {}
};
bool operator<(const Point &p1, const Point &p2) {
    return (p1.x < p2.x) || (p1.x == p2.x && p1.y < p2.y);
}
bool compare_y(const Point &p1, const Point &p2) {
    return p1.y < p2.y;
}

double ClosestPair(vector<Point>::iterator begin, vector<Point>::iterator end) {
    const int n = end - begin;
    if (n <= 1)
        return numeric_limits<double>::max();
    int m = n / 2;
    double x = (begin + m)->x;
    double d = min(ClosestPair(begin, begin + m), ClosestPair(begin + m, end));
    inplace_merge(begin, begin + m, end, compare_y);

    vector<Point> b;
    for (auto it = begin; it != end; ++it) {
        if (d <= abs(it->x - x))
            continue;

        for (size_t i = 0; i < b.size(); ++i) {
            double dx = it->x - b[b.size() - i - 1].x;
            double dy = it->y - b[b.size() - i - 1].y;
            if (d <= dy)
                break;
            d = min(d, sqrt(dx * dx + dy * dy));
        }
        b.emplace_back(*it);
    }

    return d;
}

double Solve(vector<Point> &p) {
    sort(p.begin(), p.end());
    return ClosestPair(p.begin(), p.end());
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(15) << setiosflags(ios::fixed); // printf("%.4f", x);

    int n;

    cin >> n;
    vector<Point> p(n);
    for (int i = 0; i < n; ++i)
        cin >> p[i].x >> p[i].y;

    cout << Solve(p) << endl;

    return 0;
}