import Data.Ratio
  
main :: IO ()
main = do
  n <- readLn
  xs <- map read . words <$> getLine
  print $ solve n xs

solve :: Int -> [Int] -> Int
solve n xs = sum [ (x - p) ^ 2 | x <- xs ]
  where p = round $ (sum xs) % n
