#include <bits/stdc++.h>
using namespace std;
long long distance(pair<long long, long long> p1, pair<long long, long long> p2) {
return (p1.first - p2.first)*(p1.first - p2.first) + (p1.second - p2.second)*(p1.second - p2.second);
}
long long solve_rec(vector<pair<long long, long long>> &points, int begin, int end) {
if (end - begin == 2) {
return distance(points[begin], points[begin+1]);
}
else if (points.size() == 3) {
return min(
distance(points[begin], points[begin+1]),
distance(points[begin+1], points[begin+2]),
distance(points[begin], points[begin+2])
);
}
long long N = (end - begin);
long long M = begin + N / 2;
long long left = solve_rec(points, begin, M);
long long right = solve_rec(points, M, end);
long long d = min(left, right);
vector<pair<long long, long long>> around;
for (int i = 0; i < N; i++) {
if (abs(points[begin+i].first - points[M].first) < d) {
around.push_back(points[begin+i]);
}
}
sort(around.begin(), around.end(), [] (const auto& lhs, const auto& rhs) {
return lhs.second < rhs.second;
});
int size = (int) around.size();
for (int i = 0; i < size; ++i) {
for (int j = i+1; j < size && (around[j].second - around[i].second) < d; j++) {
long long dist = distance(around[i], around[j]);
if (dist < d)
d = dist;
}
}
return d;
}
float solve(vector<pair<long long, long long>> &points) {
return solve_rec(points, 0, points.size());
}
int main() {
int n;
cin >> n;
vector<pair<long long, long long>> points(n);
for (int i = 0; i < n; i++)
cin >> points[i].first >> points[i].second;
sort(points.begin(), points.end());
cout << solve(points) << endl;
}