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

let n = Int(readLine()!)!
let ai = readInts().sorted { $0 > $1 }
var alice = 0
var bob = 0
stride(from: 0, to: n, by: 2).forEach { alice += ai[$0] }
stride(from: 1, to: n, by: 2).forEach { bob += ai[$0] }
print(alice - bob)