function Main(input) {
    var num = input.split('\n')[0];
    var field = input.split('\n')[1];
    var array = field.split(' ');
    var alice =[];
    var bob =[];
    array.sort(function(a, b) {
        return b - a;
    });
    var aliceNum = num/2;
    var bobNum = 0;
    if(num%2===0){
        bobNum=num/2;
    }else{
         bobNum=Math.round(num/2)-1;
    }
    for(var i =0; i<array.length; i++){
        if(i%2===0){
            alice.push(array[i]);
        }else{
             bob.push(array[i]);
        }
    }
    var aliceTotal =0;
    for(var j =0; j<alice.length; j++){
        aliceTotal+=Number(alice[j]);
    }
        var bobTotal =0;
    for(var k =0; k<bob.length; k++){
        bobTotal+=Number(bob[k]);
    }
    console.log(aliceTotal-bobTotal)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));