var sum  = function(arr) {
    return arr.reduce(function(prev, current, i, arr) {
        return prev+current;
    });
};

function main(input) {
  	input = input.split("\n");
    const args = input[1].split(' ').map(n =>{
      return parseInt(n, 10);
    });
    const args_sorted = args.sort(
      function(a,b){
        return (a < b ? 1 : -1);
      }
    );
    const odd_numbers = args_sorted.filter((n, i) => {
      if (i % 2 == 0) return n;
    });
    const even_numbers = args_sorted.filter((n, i) => {
      if (i % 2 != 0) return n;
    });
    console.log(sum(odd_numbers) - sum(even_numbers));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));