'use strict'

function main(s) {

  s = s.split('\n');
  const n = Number(s[0]);
  const cards = s[1].split(' ').map(x => Number(x));
  cards.sort((a, b) => b - a);

  let alice = 0;
  let bob   = 0;

  for (var i = 0; i < n; i++) {
    if ((i % 2) === 0) {
      alice += cards.shift();
    } else {
      bob += cards.shift();
    }
  }

  const ans = alice - bob;
  console.log(ans);
}

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