process.stdin.resume();
process.stdin.setEncoding('utf8');
 
var lines = [];
var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
reader.on('line', (line) => {
    // ここで入力を処理する
    lines.push(line);
});
var sub_fn = (ary)=>{
  
}
reader.on('close', () => {
  var x = (lines[1].split(' ')).map((a)=>{return 1*a}).sort(function(a,b){
        if( a > b ) return -1;
        if( a < b ) return 1;
        return 0;
});
  var al = 0;
  var bb = 0;
  for(var i in x){
    if(i%2 == 0){
     // console.log(x[i])
      al += x[i]
    }else{
      bb += x[i]
    }   
  }
  console.log(al - bb)
});