import Data.List

main :: IO ()
main = do
  n <- readLn :: IO Int
  xs <- reverse . sort . map read . words <$> getLine :: IO [Int]
  let l = length xs `div` 2
  print $ if odd l then (sum $ take (l+1) xs) - (sum $ drop (l+1) xs) else sum (take l xs) - sum (drop l xs)