import Control.Applicative
import Data.List

main :: IO ()
main = do
  { [n] <- readLineInputs :: IO [Int]
  ; xs  <- readLineInputs
  ; print $ solve xs
  }


{- |
>>> solve [1, 4]
5
>>> solve [14, 14, 2, 13, 56, 2, 37]
2354
-}
solve :: [Int] -> Int
solve xs = iter [1 .. 100] (maxBound :: Int)
  where
    iter []     e = e
    iter (p:ps) e = iter ps (min e (foldr ((+) . (^2) . subtract p) 0 xs))

readLineInputs :: Read a => IO [a]
readLineInputs = map read . words <$> getLine
