main :: IO ()
main = do
  _ <- getLine
  n <- fmap read . words <$> getLine :: IO [Int]
  print . minimum $ fmap (getCost n) [-100..100]

getCost :: [Int] -> Int -> Int
getCost ls n = sum $ fmap (cost n) ls where
  cost n1 n2 =  (n1 - n2) ^ (2 :: Int)
