function main(input){
    const args = input.split("\n");
    const N = parseInt(args[0],10),
        cards = args[1].split(" ").map(n => parseInt(n, 10));
        
    var aSum = 0,
        bSum = 0;
    
    cards.sort((a, b)=> a - b).foreach((n, i)=> {
        (i % 2 === 0)? aSum += n: bSum += n;
    });

    console.log(aSum - bSum);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));