process.stdin.resume();
process.stdin.setEncoding('utf8');
// 自分の得意な言語で
// Let's チャレンジ！！

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
  
  var num = parseInt(lines[0],10);

  var card = lines[1].split(' ');
  
  var hairetu = [];
  for(var i=0;i<card.length;i++){
  	hairetu.push(parseInt(card[i],10));
  }
  

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

　hairetu.sort(compareFunc);
 var alice =0;
 var bob = 0;
  
 for(var i=0;i<hairetu.length;i++){
 	if(i%2 ===0){
    	alice += hairetu[i];
    }else{
    	bob += hairetu[i];
    }
 } 
  
  console.log(alice-bob);

  
  
});