'use strict'

function Main(input) {
  const inputList = input.split('\n');
  const n = inputList[0]
  const numberStringList = inputList[1].split(' ')
  let numberList = []
  for (let i=0; i<n; i++) {
    numberList.push(Number(numberStringList[i]))
  }
  const sortedNumberList = bubbleSort(numberList)

  let aliceTotal = 0
  let bobTotal = 0
  for (let i=0; i<n; i++) {
    if (i%2 === 0) {
      aliceTotal += sortedNumberList[n-i-1]
    } else {
      bobTotal += sortedNumberList[n-i-1]
    }
  }

  const result = aliceTotal - bobTotal

  console.log(result)
}

function bubbleSort(array) {
  let sortedArray = array.concat()

  for (let i=0; i<sortedArray.length-1; i++) {
    for (let j=0; j<sortedArray.length-1-i; j++) {
      if (sortedArray[j] > sortedArray[j+1]) {
        const tmp = sortedArray[j]
        sortedArray[j] = sortedArray[j+1]
        sortedArray[j+1] = tmp
      }
    }
  }

  return sortedArray
}

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