"use strict";

function main(input){
  const args = input.trim().split('\n');
  const n = parseInt(args[0],10);
  const arr = args[1].split(' ').map(_=>parseInt(_,10));
  arr.sort((a,b)=>b-a);
  
  let a = 0,
      b = 0;
  for(let i=0; i<n; i++){
    if(i%2==0) a+=arr[i]; else b += arr[i];
  }
  
  console.log(a - b);
}

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