import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
import Data.Array.Unboxed
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete

maximumOrDefault d xs = if null xs then d else maximum xs

pillars :: [(Int, Int)] -> UArray (Int, Int) Bool
pillars xs = runSTUArray $ do
    arr <- newArray ((0,0), (5000, 5000)) False :: ST s (STUArray s (Int,Int) Bool)
    forM_ xs $ flip (writeArray arr) True
    return arr

main = do
    n <- getInt
    when (n/=0) $ do
        ds <- map (apply2 (,)) <$> replicateM n getInts
        let arr = pillars ds
        print $ maximumOrDefault 0 [dx ^ 2 + dy ^ 2| (x1,y1) <- ds, (x2,y2) <- ds, (x1/=x2 || y1/=y2), let dx = x2 - x1, let dy = y2 - y1, let (x3,y3) = (x1-dy,y1+dx), let (x4,y4) = (x2-dy,y2+dx), 0<=x3, x3<=5000, 0<=y3, y3<=5000, 0<=x4, x4<=5000, 0<=y4, y4<=5000, arr!(x3,y3), arr!(x4,y4)]
        main