import Data.List

play :: [Int] -> Int
play l = iter 0 0 (reverse (sort l)) where
    iter a b [] = a - b
    iter a b [x] = x + a - b
    iter a b (x:y:xs) = iter (a+x) (b+y) xs

readData :: IO [Int]
readData = do
    line1 <- getLine
    let xs = map (\x -> read x :: Int) (words line1)
    return xs

main :: IO() 
main = do
    n  <- readLn :: IO Int
    la <- readData
    let ans = play (take n la)
    print ans