"use strict";
function Main(input) {
  input = input.split("\n");
  let tmp = input[1].split(" ");

  tmp.sort(function (a, b) {
    return a < b ? 1 : -1;
  });

  let result = 0;
  for (const n in tmp) {
    if (n % 2 == 0) {
      result = result + parseInt(tmp[n]);
    } else {
      result = result - parseInt(tmp[n]);
    }
  }
  console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf-8"));
