import Data.List

step (a,b) (i,e)
  | odd i = (a+e,b)
  | otherwise = (a,b+e)

main = do
  n <- readLn :: IO Int
  xs <- zip [1..n] . sortBy (flip compare) . map read . words <$> getLine :: IO [(Int, Int)]
  let (a,b) = foldl' step (0,0) xs
  print $ abs $ a - b
  