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 <cstdio>
#include <vector>
#include <unordered_map>
#include <algorithm>

using namespace std;

template<class T>
struct Vec2
{
	Vec2(){}
	Vec2(T _x, T _y) : x(_x), y(_y) {}

	Vec2 operator+(const Vec2& rhs) const { return Vec2(x + rhs.x, y + rhs.y); }
	Vec2 operator-(const Vec2& rhs) const { return Vec2(x - rhs.x, y - rhs.y); }
	T sqlength() const { return x*x + y*y; }

	T x, y;
};

typedef Vec2<double> Vec;
typedef long long ll;

static int Rand()
{
	static int r = 123456789;
	r = r ^ (r << 13);
	r = r ^ (r >> 17);
	r = r ^ (r << 5);
	return r;
}

inline static ll Cell(const Vec& p, double w)
{
	return  (ll(p.x / w) << 32) + ll(p.y / w);
}

int main()
{
	int n = 0;
	cin >> n;

	vector<Vec> P;
	P.reserve(n);
	for (int i = 0; i < n; i++) {
		double x, y;
		scanf("%lf%lf", &x, &y);
		P.push_back(Vec(x+200,y+200));
	}

	int ip = Rand()%P.size();
	double w = 1000000.0;
	for (size_t i = 0; i < P.size(); i++) {
		if (i != ip) {
			double d = (P[i] - P[ip]).sqlength();
			w = min(w,d);
		}
	}
	w = sqrt(w) * 1.01;

	unordered_map<ll, vector<size_t>> grid;
	for (size_t i = 0; i < P.size(); i++) {
		grid[Cell(P[i], w)].push_back(i);
	}

	double ans = 1000000.0;
	for (size_t i = 0; i < P.size(); i++) {
		const ll c = Cell(P[i], w), X = ll(1)<<32;
		const ll neighbors[9] = { c - X - 1, c - X, c - X + 1, c - 1, c, c + 1, c + X - 1, c + X, c + X + 1 };
		vector<size_t> v;
		for (int j = 0; j < 9; j++) {
			auto it = grid.find(neighbors[j]);
			if (it == grid.end()) continue;
			for (const auto& k : it->second) {
				if (k != i) {
					double d = (P[k] - P[i]).sqlength();
					ans = min(ans, d);
				}
			}
		}
	}
	printf("%.10f\n", sqrt(ans));
	return 0;
}
