'use strict';
function main(input) {
    var args = input.split('\n')[1].split(' ').map((n) => parseInt(n, 10));
	var sorted = args.sort((a,b)=>a-b).reverse()
    let alice = 0
    let bob = 0
    sorted.forEach((a,i)=>{
      if(i%2 === 0) {
        alice += a
      }else{
        bob+=a
      }
    })
  	console.log(alice-bob)
  	
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));