function main( input ) {
    const args = input.split('\n');
    const N = parseInt(args[0], 10);
    const cards = args[1].split(' ').map( n => parseInt(n, 10) );
    let aSum = 0, bSum = 0;
    cards.sort( (a, b) => a < b ? 1 : -1 ).forEach( (v, i) => {
        (i%2 === 0) ? aSum += v : bSum += v;
    })
    console.log( aSum - bSum );
}

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