import Foundation
let rdInt = Int(readLine()!)!
var rdArr = readLine()!.split(separator: " ").map({Int($0)!}).sorted{$0 > $1}


var aliceArr = 0
var bobArr = 0

for i in 0 ..< rdInt{
    
    if i.isMultiple(of: 2) {
        aliceArr += rdArr[i]
    } else {
        bobArr += rdArr[i]
    }
}
print(aliceArr - bobArr)