import Foundation


func readStr() -> String {
  return readLine()!
}

func readInt() -> Int {
    return Int(readLine()!)!
}

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

func readTwoInts() -> (a: Int, b: Int) {
    let ints = readLine()!.split(separator: " ").map { Int($0)! }
    return (a: ints[0], b: ints[1])
}

let N = readInt()
var A = readInts()
let Alice = A.sorted { $0 > $1 }.enumerated().filter{ $0.0 % 2 == 0 }.map{ $0.1 }.reduce(0, +)
let Bob = A.sorted { $0 > $1 } .enumerated().filter{ $0.0 % 2 != 0 }.map{ $0.1 }.reduce(0, +)
print(Alice - Bob)

