main = do
 a <- (read::String->Double) <$> getLine
 b <- map (read::String->Double).words <$> getLine
 print . show .floor. minimum $ [f (fromIntegral.ceiling .average b $a) b, 
 						   f (fromIntegral.floor   .average b $a) b]

f ::  Double -> [Double] -> Double
f x y = sum $ map (\h -> (h-x)*(h-x) ) y


average :: [Double] -> Double -> Double
average b a =  sum b / a
