import Data.List
main=interact $ show.minimum.f.map read.words.head.tail.lines
f::[Int]->[Int]
f x = map (g x) [-100..100]
g::[Int]->Int->Int
g x y = sum $ map (h y) x
h::Int->Int->Int
h y a = (y-a)^2