'use strict';

function main(input) {
  let inputs = input.split('\n');
  let cards = inputs[1].split(' ').map(n => parseInt(n, 10));
  let alice_sum = 0;
  let bob_sum = 0;

  let sorted_cards = cards.sort(compareNumbers);

  sorted_cards.forEach((card, i) => {
    if (i === 0 || i % 2 === 0) {
      alice_sum += card;
    } else {
      bob_sum += card;
    }
  });

  console.log(alice_sum - bob_sum);
}

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

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
