ceilDiv :: Integral a => a -> a -> a
ceilDiv t s = (t + s - 1) `div` s

main :: IO ()
main = do
    n <- readLn :: IO Int
    x <- map read . words <$> getLine :: IO [Int]
    let p = sum x `ceilDiv` n
        f a i = a + (i - p) ^ 2
    print $ foldl f 0 x