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

  let sortArr = [];
  let n = 0;
  while (tmp.length > 0) {
    let current = 0;
    let currentNum;
    for (const i in tmp) {
      if (tmp[i] > current) {
        current = tmp[i];
        currentNum = i;
      }
    }
    tmp.splice(currentNum, 1);
    sortArr[n] = current;
    n++;
  }

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

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