import           Data.List

main :: IO ()
main = do
    n <- readLn :: IO Int
    as <- map read . words <$> getLine :: IO [Int]
    print $ solve $ sortBy (flip compare) as

solve ns = let ns' = zip [1..] ns
               as = map snd
                   $ filter ((== 1) . (`mod` 2). fst) ns'
               bs = map snd
                   $ filter ((== 0) . (`mod` 2) . fst) ns' in
               sum as - sum bs
