function main(inputs) {
  const N = inputs[0]
  const a = inputs[1].split(' ').map(Number)
  let sorted = a.sort((b, c) => { return b < c ? 1 : -1 })
  const r = sorted.reduce((h, e, i) => {
      if (i % 2 === 0) {
        return h + e
      } else {
        return h - e
      }
    }, 0)
  console.log(r)
}

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