const args = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');
const n = parseInt(args[0], 10);
const list = args[1].split(' ').map(function(x){return parseInt(x, 10)}).sort();
var alice = 0;
var bob = 0;
for (var i=0; i<list.length; i++) {
  if(i%2 === 0) {
    alice += list[i]
  } else {
    bob += list[i]
  }
}
console.log(alice - bob);