import Data.List

f ::[Int]->Int->Int->Int
f [] a b=a-b
f (x:[]) a b = a+x-b
f (x:y:zs) a b= f zs (a+x) (b+y)


main = do
       n<-getLine
       a<-getLine
       let n1=read n::Int
           a1=reverse $ sort $ map read (words a)::[Int]
       putStrLn $ show $ f a1 0 0