import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

struct S {
    int x, y;
    int opCmp(const ref S s) const {
        if (x == s.x) {
            return y - s.y;
        }
        return x - s.x;
    }
}

int f(S[] a) {
    if (a.length <= 32) return h(a);
    int ret = min(f(a[0 .. $ / 2]), f(a[$ / 2 .. $]));
    int border = a[$ / 2].x;
    foreach (i; 0 .. a.length) {
        if (!(border - ret < a[i].x && a[i].x < border)) continue;
        int lb = 0, ub = cast(int)a.length;
        while (lb + 1 < ub) {
            int mid = (lb + ub) / 2;
            if (border  - ret <= a[mid].x && a[mid].x <= border) {
                lb = mid;
            } else {
                ub = mid;
            }
        }
        foreach (p; a[lb .. ub]) {
            if (p.y - a[i].y >= ret) continue;
            ret = min(ret, d(a[i], p));
        }
    }
    return ret;
}

int h(S[] a) {
    int ret = int.max;
    foreach (i; 0 .. a.length) {
        foreach (j; i + 1 .. a.length) {
            ret = min(ret, d(a[i], a[j]));
        }
    }
    return ret;
}

int d (const ref S a, const ref S b) {
    return square(a.x - b.x) + square(a.y - b.y);
}

int square(int x) {
    return x * x;
}

void main() {
    int n; readf("%d\n", &n);
    S[] ps = new S[n];
    foreach (i; 0 .. n) {
        readf("%d %d\n", &ps[i].x, &ps[i].y);
    }
    ps = ps.sort.array;
    f(ps).writeln;
}