function main (input) {
    var N = input.split('\n')[0];
    var card = (input.split('\n')[1].split(' ')).sort();
    card = card.map(function(e){return Number(e);});
    var a = 0;
    var b = 0;
    for (var n = 0; n < N; n++) {
        if (n%2 === 0){
            a = a + card[card.length-1];
            card.pop();
        } else {
            b = b + card[card.length-1];
            card.pop();
        }
    }
    console.log(Math.abs(a-b));
}

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