import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as Map
import Data.Array
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
bsreadInt :: BC.ByteString -> Int
bsreadInt = fst . fromJust . BC.readInt
strToInt s = (read :: String -> Int) s

main = do

   n <- readLn :: IO Int
   an <- reverse. sort . map bsreadInt . BC.words <$> BC.getLine
   print $ solve an 0 0 0
   
solve :: [Int] -> Int -> Int -> Int -> Int
solve [] n x y = x-y
solve (a:an) 0 x y = solve an 1 (x+a) y
solve (a:an) 1 x y = solve an 0 x (y+a)