import Control.Applicative ((<$>), (<*>))
import Data.List (sort)

main :: IO ()
main = solve <$> readLn <*> (sort <$> map read <$> words <$> getLine) >>= print

solve :: Int -> [Int] -> Int
solve n = sum . zipWith f [1..n]
  where f x y = abs (x - y)