from operator import itemgetter

N = int(eval(input()))

a = [tuple(map(int, input().split())) for _ in [0]*N]

ans = float("inf")



a.sort()

for (x1, y1), (x2, y2) in zip(a, a[1:]):

    dist = (x1-x2)**2 + (y1-y2)**2

    if ans > dist:

        ans = dist



a.sort(key=itemgetter(1))

for (x1, y1), (x2, y2) in zip(a, a[1:]):

    dist = (x1-x2)**2 + (y1-y2)**2

    if ans > dist:

        ans = dist



print(ans)

import sys

from operator import itemgetter

N = int(eval(input()))

a = sorted(tuple(map(int, l.split())) for l in sys.stdin.readlines())

ans = float("inf")



for (x1, y1), (x2, y2) in zip(a, a[1:]):

    dist = (x1-x2)**2 + (y1-y2)**2

    if ans > dist:

        ans = dist



a.sort(key=itemgetter(1))

for (x1, y1), (x2, y2) in zip(a, a[1:]):

    dist = (x1-x2)**2 + (y1-y2)**2

    if ans > dist:

        ans = dist



print(ans)

from operator import itemgetter

N = int(eval(input()))
a = [tuple(map(int, input().split())) for _ in [0] * N]
ans = float("inf")
a.sort()
for (x1, y1), (x2, y2) in zip(a, a[1:]):
    dist = (x1 - x2) ** 2 + (y1 - y2) ** 2
    if ans > dist:
        ans = dist
a.sort(key=itemgetter(1))
for (x1, y1), (x2, y2) in zip(a, a[1:]):
    dist = (x1 - x2) ** 2 + (y1 - y2) ** 2
    if ans > dist:
        ans = dist
print(ans)

import sys
from operator import itemgetter

N = int(eval(input()))
a = sorted(tuple(map(int, l.split())) for l in sys.stdin.readlines())
ans = float("inf")
for (x1, y1), (x2, y2) in zip(a, a[1:]):
    dist = (x1 - x2) ** 2 + (y1 - y2) ** 2
    if ans > dist:
        ans = dist
a.sort(key=itemgetter(1))
for (x1, y1), (x2, y2) in zip(a, a[1:]):
    dist = (x1 - x2) ** 2 + (y1 - y2) ** 2
    if ans > dist:
        ans = dist
print(ans)

+import sys -a = [tuple(map(int, input().split())) for _ in [0] * N] +a = sorted(tuple(map(int, l.split())) for l in sys.stdin.readlines()) -a.sort()