let n = Int(readLine()!)!
let sortedrArray = readLine()!.characters.split{$0 == " "}.map{Int(String($0))!}.sort{$1 < $0}
var aliceTotal = 0
var bobTotal = 0
var aliceTurn = true
for i in sortedrArray {
    if(aliceTurn) {
        aliceTotal += i
    } else {
        bobTotal += i
    }
    
   aliceTurn = !aliceTurn
}

print(aliceTotal - bobTotal)
