import Control.Monad
import Control.Applicative
import Data.List

main = do

    n <- getLine
    xs <- map read . words <$> getLine
    
    let costlist = [costs x xs | x <- [-100,-99..100]]
    
    print (minimum costlist)

costs x xs = sum (map (cost x) xs)
cost x y = (x-y) * (x-y)
