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 += 2) {
		sub += Math.floor(cards[i] - (cards[i + 1] || 0));
	}
	console.log(sub);
}
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));
