import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

main :: IO ()
main = do
    [n] <- getIntList
    xl <- getIntList
    let p = properFraction $ (fromIntegral . sum) xl / fromIntegral n
    let consL = consumptionSum (fst p) xl
    let consR = consumptionSum (fst p + 1) xl
    putStrLn . show $ if consL < consR then consL else consR

consumptionSum :: (Integral a) => a -> [a] -> a
consumptionSum p = sum . map (\x -> (x-p)^2)

readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BS.getLine