function Main(input) {
  const arr = input.split('\n')
  const num = arr[1].split(' ').map(x => Number(x));
  var alice = 0;
  var bob = 0;

  num.sort((a, b) => b - a);
  num.forEach((item, index) => {
    if (index % 2 === 0) {
      alice += item;
    } else {
      bob += item;
    }
  });

  console.log(alice - bob);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));