'use strict'

function main(input) {

    input = input.split(/\n/)
    const n = ~~input[0]
    const cards = input[1].split(/\s/).map(v => ~~v).sort((a, b) => b - a)

    let a = 0
    let b = 0
    for (let i = 0; i < n; i++) {

        if (i % 2 === 0) a += cards[i]
        else b += cards[i]
    }

    console.log(a - b)
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));