func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let _ = readLine()
    let ints = readInts().sorted(by: {$0 > $1})
    
    var a = 0
    var b = 0
    var isA = true
    for i in ints {
        if isA {
            a += i
        } else {
            b += i
        }
        isA.toggle()
    }
    
    print("\(a - b)")
}

main()
