import Data.Char
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as BS
main = do
  n <- readLn :: IO Int
  xs <- VU.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  print $ VU.minimum $ VU.map (\i -> VU.sum $ VU.map (\x -> (x-i)^2) xs) $ VU.enumFromN (-100::Int) 201