import Data.List.Split
import Data.List
main :: IO ()
main = do
    getLinea :: IO Int
    a <- getLine >>= return . map read . splitOn " " :: IO [Int]
    putStrLn . show $ solve a
    where
        getLinea :: Read a => IO a
        getLinea = getLine >>= (return . read)
        sep2 :: [Int] -> [(Int,Int)]
        sep2 [] = []
        sep2 [x] = [(x,0)]
        sep2 (x:y:xs) = (x,y):sep2 xs
        solve :: [Int] -> Int
        solve = foldr (\(x,y) sum -> sum + (x - y)) 0 . sep2 . reverse . sort