import Data.List
import Data.Vector as V hiding (map,sum,reverse) 
main = do
  getLine 
  a <- map read . words <$> getLine 
  let a' = sort a
      b = reverse a'
      a'' = fromList b
      ans = sum [a'' ! i | i <- [0,2 .. V.length a''-1]] - sum [a'' ! i | i <- [1,3 .. V.length a''-1]]
  print ans
