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

func main() {
    let count = Int(readLine()!)!
    var ints = readInts()
    
    var a = 0
    var b = 0
    var isA = true
    for _ in 1...count {
        guard let max = ints.max(), let maxIndex = ints.firstIndex(of: max) else {
            break
        }
        if isA {
            a += max
        } else {
            b += max
        }
        ints.remove(at: maxIndex)
        isA.toggle()
    }
    
    print("\(a - b)")
}

main()
