# -*- coding: utf-8 -*-

"""

http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0585



"""

import sys

from sys import stdin

from collections import namedtuple

input = stdin.readline





def closest_part(points, n):

    # ?????¬???p324???

    if n <= 1:

        return float('inf')

    m = n // 2

    x = points[m].x

    d = min(closest_part(points[:m], m), closest_part(points[m:], n-m))



    points.sort(key=lambda p:p.y)

    b = []

    for p in points:

        if (p.x - x)**2 >= d:

            continue

        for j in range(len(b)):

            dx = p.x - b[-j-1].x

            dy = p.y - b[-j-1].y

            if dy**2 >= d:

                break

            d = min(d, (dx**2 + dy**2))

        b.append(p)

    return d



pos = namedtuple('pos', ['x', 'y'])

def main(args):

    n = int(eval(input()))

    points = [pos(*list(map(int, input().split()))) for _ in range(n)]

    points.sort()               #  x????????§??????????????????



    result = closest_part(points, n)

    print(result)





if __name__ == '__main__':

    main(sys.argv[1:])
# -*- coding: utf-8 -*-

"""

http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0585



"""

import sys

from sys import stdin

from collections import namedtuple

input = stdin.readline





def closest_part(points, n):

    # ?????¬???p324???

    if n <= 1:

        return float('inf')

    m = n // 2

    x = points[m][0]

    d = min(closest_part(points[:m], m), closest_part(points[m:], n-m))



    points.sort(key=lambda p:p[1])

    b = []

    for p in points:

        if (p[0] - x)**2 >= d:

            continue

        for q in b[::-1]:

            # dx = p[0] - b[-j-1][0]

            # dy = p[1] - b[-j-1][1]

            dx = p[0] - q[0]

            dy = p[1] - q[1]

            if dy**2 >= d:

                break

            d = min(d, (dx**2 + dy**2))

        b.append(p)

    return d



def main(args):

    n = int(eval(input()))

    points = [tuple(map(int, input().split())) for _ in range(n)]

    points.sort()               #  x????????§??????????????????



    result = closest_part(points, n)

    print(result)





if __name__ == '__main__':

    main(sys.argv[1:])
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0585
"""
import sys
from sys import stdin
from collections import namedtuple

input = stdin.readline


def closest_part(points, n):
    # ?????¬???p324???
    if n <= 1:
        return float("inf")
    m = n // 2
    x = points[m].x
    d = min(closest_part(points[:m], m), closest_part(points[m:], n - m))
    points.sort(key=lambda p: p.y)
    b = []
    for p in points:
        if (p.x - x) ** 2 >= d:
            continue
        for j in range(len(b)):
            dx = p.x - b[-j - 1].x
            dy = p.y - b[-j - 1].y
            if dy**2 >= d:
                break
            d = min(d, (dx**2 + dy**2))
        b.append(p)
    return d


pos = namedtuple("pos", ["x", "y"])


def main(args):
    n = int(eval(input()))
    points = [pos(*list(map(int, input().split()))) for _ in range(n)]
    points.sort()  #  x????????§??????????????????
    result = closest_part(points, n)
    print(result)


if __name__ == "__main__":
    main(sys.argv[1:])

# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0585
"""
import sys
from sys import stdin
from collections import namedtuple

input = stdin.readline


def closest_part(points, n):
    # ?????¬???p324???
    if n <= 1:
        return float("inf")
    m = n // 2
    x = points[m][0]
    d = min(closest_part(points[:m], m), closest_part(points[m:], n - m))
    points.sort(key=lambda p: p[1])
    b = []
    for p in points:
        if (p[0] - x) ** 2 >= d:
            continue
        for q in b[::-1]:
            # dx = p[0] - b[-j-1][0]
            # dy = p[1] - b[-j-1][1]
            dx = p[0] - q[0]
            dy = p[1] - q[1]
            if dy**2 >= d:
                break
            d = min(d, (dx**2 + dy**2))
        b.append(p)
    return d


def main(args):
    n = int(eval(input()))
    points = [tuple(map(int, input().split())) for _ in range(n)]
    points.sort()  #  x????????§??????????????????
    result = closest_part(points, n)
    print(result)


if __name__ == "__main__":
    main(sys.argv[1:])

-    x = points[m].x +    x = points[m][0] -    points.sort(key=lambda p: p.y) +    points.sort(key=lambda p: p[1]) -        if (p.x - x) ** 2 >= d: +        if (p[0] - x) ** 2 >= d: -        for j in range(len(b)): -            dx = p.x - b[-j - 1].x -            dy = p.y - b[-j - 1].y +        for q in b[::-1]: +            # dx = p[0] - b[-j-1][0] +            # dy = p[1] - b[-j-1][1] +            dx = p[0] - q[0] +            dy = p[1] - q[1] -pos = namedtuple("pos", ["x", "y"]) - - -    points = [pos(*list(map(int, input().split()))) for _ in range(n)] +    points = [tuple(map(int, input().split())) for _ in range(n)]