function main(input) {
	const args = input.split('\n');
  	const N = args[0];
    let arr = args[1].split(' ').map((n) => parseInt(n, 10));
  			
  	let aSum = 0;
    let bSum = 0;
    
    arr.sort((a, b) => b - a);
  
  	arr.forEach((v, i) => {
      i % 2 === 0 ? aSum += v : bSum += v
    });
  
  	console.log(aSum - bSum);
}

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