'use strict'

const main = input => {
	const args = input.split('\n')
	const n = parseInt(args[0], 10)
	const a = args[1].split(' ').map(Number).sort((a, b) => b - a)
	let alice = 0
	let bob = 0

	for (let i = 0; i < n; i++) {
		if (i % 2 === 0) {
			alice += a[i]
		} else {
			bob += a[i]
		}
	}

	console.log(alice - bob)
}

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