function main(s) {
	n = Number(s.split('\n')[0]);
	a = s.split('\n')[1].split(' ').map(x => Number(x))
	a.sort(
		function (a, b) {
			return (a < b ? 1 : -1);
		}
	)

	var x = 0;
	var y = 0;
	for (var i = 0; i < a.length; i++ ) {
		if (i%2 === 0) {x += a[i]} else {y += a[i]};
	}

	console.log(Math.abs(x - y));
}

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