### constant

MAX_X = 5000
MAX_Y = 5000

### main

loop do
  n = gets.strip.to_i
  break if n == 0

  pts = []
  brd = (MAX_Y + 1).times.map{{}}

  n.times do
    x, y = gets.strip.split(' ').map{|s| s.to_i}
    pts << [x, y]
    brd[y][x] = true
  end

  npts = pts.length
  max_area = 0

  for i in (0...npts)
    x0, y0 = pts[i]
    for j in ((i + 1)...npts)
      x1, y1 = pts[j]
      dx = x1 - x0
      dy = y1 - y0

      for v in [[-dy, dx], [dy, -dx]]
        x2 = x0 + v[0]
        y2 = y0 + v[1]
        x3 = x1 + v[0]
        y3 = y1 + v[1]

        if x2 >= 0 && x2 <= MAX_X && y2 >= 0 && y2 <= MAX_Y &&
            x3 >= 0 && x3 <= MAX_X && y3 >= 0 && y3 <= MAX_Y &&
            brd[y2][x2] && brd[y3][x3]
          area = dx * dx + dy * dy
          max_area = area if max_area < area
        end
      end
    end
  end

  puts max_area
end