"use strict";

var main = function main(input) {
  var N = parseInt(input.split("\n")[0]);
  var a = input.split("\n")[1].split(" ");
  a.sort(function (a, b) {
    return b - a;
  });
  var num = a.length;
  var Alice = 0;
  var Bob = 0;

  for (var i = 0; i < num; i++) {
    if (i % 2 == 0) {
      Alice += parseInt(a[i], 10);
    } else {
      Bob += parseInt(a[i], 10);
    }
  }

  console.log(Alice - Bob);
};

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