'use strict';
let execute = input => {
  let cardList = input.split('\n')[1].split(' ').map(str => +str).sort().reverse();
  return cardList.reduce((prev, cur, idx) => prev += (idx % 2 === 0) ? cur : cur * -1, 0);
};
function Main(input) {
  console.log(execute(input));
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));