import qualified Data.ByteString.Char8 as C
import Data.List

r' = unfoldr (C.readInt . C.dropWhile (==' ')) <$> C.getLine


main = getLine >> r' >>= print.solve

solve :: [Int] -> Int
solve xs = minimum $ do
    t <- [-100..100]
    return $ sum $ map ((^2).(t-)) xs