function Main(input) {
  "use strict";
  const lines = input.split("\n");
  const line1 = lines[0].split(" ");
  const line2 = lines[1].split(" ");

  const N = parseInt(line1[0], 10);
  const As = line2.map(s => parseInt(s, 10))
  As.sort((a,b) => b - a)

  var t_a = 0;
  var t_b = 0;
  for (var i = 0; i < N; i++) {
    if (i%2==0) {
      t_a += As[i]
    } else {
      t_b += As[i]
    }
  }
  console.log(t_a - t_b)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
