import Data.List

main = do
  getLine
  li <- getLine
  let xs = map read $ words li
  let ans = compute xs
  print ans

{-
-99 ～ +99 のオフセットで消費する体力の表を作っておき、
全員の分に関して1から100で必要な体力を足し合わせて最小値を得る
-}

cs = rev cs1 (0:cs1)
  where
    cs1 =[k*k | k <- [1..99]]
    rev [] xs = xs
    rev (y:ys) xs = rev ys (y:xs)

compute :: [Int] -> Int
compute xs = minimum $ map sum $ transpose $ map (\x -> take 100 $ drop (100-x) cs) xs
