function main(argString) {
	var cards = argString.split('\n')[1].split(' ').map(v => Number(v) || 0).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"));
