function Main(input){
  var In = input.split('\n');
  var cardStr = In[1].split(' ');
  var N = parseInt(In[0], 10);
  var cards = [];
  var Alice = 0;
  var Bob = 0;
  
  for(var i = 0; i < N; i++){
    var card = parseInt(cardStr[i], 10);
    cards.push(card);
  }
  
  cards.sort(function(a, b){
    return (b-a);
  });
  
  for(var j = 0; j < N; j++){
    if(j%2 == 0){
      Alice += cards[j];
    } else {
      Bob += cards[j];
    }
  }
  
  var result = Alice - Bob;
  console.log(result);
  
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));