function main(argString) {
    var cards = argString.split('\n')[1].split(' ')
        .filter(v => v.length !== 0).map(v => Number(v)).sort().reverse();
	var sub = 0;
	for (var i = 0; i < cards.length; i++) {
		sub += cards[i] * ((i % 2 === 0) ? 1 : -1);
	}
	console.log(sub);
}
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));