function Main(input){
  var inp = input.split('\n');
  var N = parseInt(inp[0].trim());
  var A = inp[1].split(' ').map(n => { return parseInt(n.trim())});

  var Alice = 0;
  var Bob = 0;
  var a = A.sort((a, b) => {
    return (parseInt(a) < parseInt(b) ? -1 : 1)})
    .reverse();
  
  for(var i = 0; i < a.length; i++){
    if(i % 2 === 0){
      Alice += a[i];
    } else { 
      Bob += a[i];
    }
  }
  console.log(Alice - Bob);
  
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
