def main():

  #points = [[False for i in range(5001)] for j in range(5001)]

  while True:

    n = int(eval(input()))

    if not n:

      break

    ps = []

    dic = {}



    for i in range(n):

      x, y = list(map(int,input().split()))

      dic[(x, y)] = 1;

      #points[x][y] = True

      ps.append((x,y))

  

    ans = 0

  

    for i in range(n):

      for j in range(n):

        p1 = ps[i]

        p2 = ps[j]

        vx = p2[0] - p1[0]

        vy = p2[1] - p1[1]

        #if  0 <= p1[0] + vy <= 5000 and 0 <= p1[1] - vx <= 5000 and 0 <= p2[0] + vy <= 5000 and 0 <= p2[1] - vx <= 5000:

        #  if  points[p1[0] + vy][p1[1] - vx] and points[p2[0] + vy][p2[1] - vx]:

        if (p1[0] + vy, p1[1] - vx) in dic and (p2[0] + vy, p2[1] - vx) in dic:

          ans = max(ans, vx ** 2 + vy ** 2)

    

    #for p in ps:

    #  points[p[0]][p[1]] = False



    print(ans)

main()  







def main():

  while True:

    n = int(eval(input()))

    if not n:

      break

    ps = []

    dic = {}



    for i in range(n):

      x, y = list(map(int,input().split()))

      dic[(x, y)] = 1;

      ps.append((x,y))

  

    ans = 0

  

    for i in range(n):

      for j in range(n):

        p1 = ps[i]

        p2 = ps[j]

        p1x = p1[0]

        p1y = p1[1]

        p2x = p2[0]

        p2y = p2[1]

        vx = p2x - p1x

        vy = p2y - p1y

        if (p1x + vy, p1y - vx) in dic and (p2x + vy, p2y - vx) in dic:

          ans = max(ans, vx ** 2 + vy ** 2)

    



    print(ans)

main()  







def main():
    # points = [[False for i in range(5001)] for j in range(5001)]
    while True:
        n = int(eval(input()))
        if not n:
            break
        ps = []
        dic = {}
        for i in range(n):
            x, y = list(map(int, input().split()))
            dic[(x, y)] = 1
            # points[x][y] = True
            ps.append((x, y))
        ans = 0
        for i in range(n):
            for j in range(n):
                p1 = ps[i]
                p2 = ps[j]
                vx = p2[0] - p1[0]
                vy = p2[1] - p1[1]
                # if  0 <= p1[0] + vy <= 5000 and 0 <= p1[1] - vx <= 5000 and 0 <= p2[0] + vy <= 5000 and 0 <= p2[1] - vx <= 5000:
                #  if  points[p1[0] + vy][p1[1] - vx] and points[p2[0] + vy][p2[1] - vx]:
                if (p1[0] + vy, p1[1] - vx) in dic and (p2[0] + vy, p2[1] - vx) in dic:
                    ans = max(ans, vx**2 + vy**2)
        # for p in ps:
        #  points[p[0]][p[1]] = False
        print(ans)


main()

def main():
    while True:
        n = int(eval(input()))
        if not n:
            break
        ps = []
        dic = {}
        for i in range(n):
            x, y = list(map(int, input().split()))
            dic[(x, y)] = 1
            ps.append((x, y))
        ans = 0
        for i in range(n):
            for j in range(n):
                p1 = ps[i]
                p2 = ps[j]
                p1x = p1[0]
                p1y = p1[1]
                p2x = p2[0]
                p2y = p2[1]
                vx = p2x - p1x
                vy = p2y - p1y
                if (p1x + vy, p1y - vx) in dic and (p2x + vy, p2y - vx) in dic:
                    ans = max(ans, vx**2 + vy**2)
        print(ans)


main()

-    # points = [[False for i in range(5001)] for j in range(5001)] -            # points[x][y] = True -                vx = p2[0] - p1[0] -                vy = p2[1] - p1[1] -                # if  0 <= p1[0] + vy <= 5000 and 0 <= p1[1] - vx <= 5000 and 0 <= p2[0] + vy <= 5000 and 0 <= p2[1] - vx <= 5000: -                #  if  points[p1[0] + vy][p1[1] - vx] and points[p2[0] + vy][p2[1] - vx]: -                if (p1[0] + vy, p1[1] - vx) in dic and (p2[0] + vy, p2[1] - vx) in dic: +                p1x = p1[0] +                p1y = p1[1] +                p2x = p2[0] +                p2y = p2[1] +                vx = p2x - p1x +                vy = p2y - p1y +                if (p1x + vy, p1y - vx) in dic and (p2x + vy, p2y - vx) in dic: -        # for p in ps: -        #  points[p[0]][p[1]] = False