#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
struct Point {
double x, y;
} point[400005];
bool operator < (const Point & a, const Point & b) {
return a.x == b.x ? a.y < b.y : a.x < b.x;
}
bool cmpy(const int & a, const int & b) {
return point[a].y < point[b].y;
}
double inline dist(double x1, double y1, double x2, double y2) {
return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
double inline dist(int i, int j) {
return dist(point[i].x, point[i].y, point[j].x, point[j].y);
}
double inline min(double a, double b) {
return a < b ? a : b;
}
int temp[400005];
double calc(int l, int r) {
if (l == r) {
return 1.0 / 0.0;
}
double d = 1.0 / 0.0;
if (l == r - 1) {
return dist(l, r);
}
int mid = (l + r) / 2;
d = min(d, min(calc(l, mid), calc(mid, r)));
int len = 0;
for (int i = l; i < r; i++) {
if (fabs(point[i].x - point[mid].x) < d) {
temp[len ++] = i;
}
}
sort(temp, temp + len, cmpy);
int i = 0;
for (int i = 0; i < len; i++) {
for (int j = i + 1; j < len && point[temp[j]].y - point[temp[i]].y < d; j++) {
d = min(d, dist(temp[i], temp[j]));
}
}
return d;
}
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%lf %lf", &point[i].x, &point[i].y);
}
sort(point, point + n);
double ans = calc(0, n);
printf("%.0lf", ans * ans);
return 0;
}