main = do
    _ <- getLine
    k <- fmap read getLine :: IO Int
    xs <- fmap (map read . words) getLine :: IO [Int]
    print $ solve k xs

solve k = foldl (\acc x -> acc + min (x * x) ((k - x) * (k - x))) 0
