function main(input){
  var str = input.split('\n');
  var int = str[1].split(' ');
  var times = parseInt(str[0]);
  var cards = [];
  for(let i=0;i<int.length;i++){
    cards.push(parseInt(int[i]));
  }
  cards.sort(function(x,y){return x-y;})
  var alice = 0;
  var bob = 0;
  for(let j=1;j<=times;j++){
    if(j%2 === 1){
      alice += cards[times-j];
    }else{
      bob += cards[times-j];
    }
  }
  console.log(alice-bob);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));