function Main(input){
  var In = input.split('\n');
  var N = parseInt(In[0], 10);
  var cards = In[1].split(' ');
  var turn = true;
  var Alice = 0;
  var Bob = 0;
  
  for(var i = 0; i < N; i++){
    cards[i] = parseint(cards[i], 10);
  }
  cards.sort(compareFunc);
  
  for(var j = 0; j < N; j++;){
    if(turn == true){
      Alice += cards[j];
    } else if(turn == false){
      Bob += cards[j];
    }
    turn != turn;
  }
  
  var result = Alice - Bob;
  console.log(result);
  
}

function compareFunc(a, b){
  return b - a;
}

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