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

func main() {
    _ = readInt()
    let cards = readInts().sorted { $0 > $1 }.enumerated()
    var point = 0
    cards.forEach {
        if $0.offset % 2 == 0 {
            point += $0.element
        } else {
            point -= $0.element
        }
    }
    print(point)
}

main()