var r1 = 0, r2  =0;
(require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')[1]).split(' ').sort((a, b) => a < b ? 1 : b < a ? -1 : 0).forEach((v, i) => i % 2 == 0 ? r1 += parseInt(v) : r2 += parseInt(v));
console.log(r1 - r2);