function main(argString) {
	var cards = argString.split('\n')[1].split(' ').sort().reverse();
  	var sub = 0;
  	for (var i = 0; i < cards.length; i += 2) {
      sub += Number(cards[i]) - Number(cards[i + 1] || 0);
    }
  	console.log(sub);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
