#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <climits>
#include <set>
#include <map>
using namespace std;
using ll = long long;
struct Point {
int x, y;
};
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<Point> points(n);
for (int i = 0; i < n; ++i) {
cin >> points[i].x >> points[i].y;
}
// 按 x 排序
sort(points.begin(), points.end(), [](const Point & a, const Point & b) {
return a.x < b.x;
});
ll minDist = LLONG_MAX;
// 使用滑动窗口
for (int i = 0; i < n; ++i) {
for (int j = i + 1; j < n; ++j) {
// 如果 x 坐标差已经大于当前最小距离,可以提前跳出
ll dx = points[i].x - points[j].x;
if (dx * dx >= minDist) break;
ll dy = points[i].y - points[j].y;
ll dist = dx * dx + dy * dy;
if (dist < minDist) {
minDist = dist;
}
}
}
cout << minDist << endl;
return 0;
}