const println = (value) => console.log(value)
const readInt = (input) => parseInt(input, 10)
const readIntList = (input) => input.split(' ').map(n => parseInt(n, 10))

function main(input) {
    const tmp = input.split('\n')
    const n = readInt(tmp[0])
    const aArray = readIntList(tmp[1]).sort().reverse()

    const alice = aArray.filter((a, index) => index % 2 == 0).reduce((acc, a) => acc + a)
    const bob = aArray.filter((a, index) => index % 2 == 1)
    const ans =  (bob.length == 0) ? alice : alice - bob.reduce((acc, a) => acc + a)
    println(ans)
}

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