{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BS
import           Data.List             (sortOn)
import           Data.Maybe            (fromJust)
import           Data.Ord              (Down (Down))
import qualified Data.Vector           as V

main :: IO ()
main = do
  n <- readLn
  as <- map readInt . BS.words <$> BS.getLine
  print $ solve n as

solve :: Int -> [Int] -> Int
solve _ as = V.sum cas - V.sum cbs where
  as' = V.fromList $ sortOn Down as
  cas = V.ifilter (\i _ -> even i) as'
  cbs = V.ifilter (\i _ -> odd i) as'

readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt
