'use strict'

function main() {
  let input = require('fs').readFileSync('/dev/stdin', 'utf8');
  input = input.trim().split(/\s+/).map(x => x - 0);
  
  const N = input.shift();
  let list = input;
  list.sort((a, b) => b - a);
  
  let result = 0;
  for(let i = 0; i < list.length; i++) {
    if(i % 2 == 0) {
      result += list[i];
    } else {
      result -= list[i];
    }
  }
  
  console.log(result);
}

main();

