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

func main() {
    let n = Int(readLine()!)!
    let A = readInts().sorted(by: >)
    
    var alice = 0
    var bob = 0
    for i in 0..<n {
        if i % 2 == 0 {
            alice += A[i]
        } else {
            bob += A[i]
        }
    }
    
    print(alice - bob)
}

main()
