'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 = mergeSort(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 mergeSort (array) {
  const sortedArray = array.concat()
  if (sortedArray.length <= 1) {
    return sortedArray
  } 

  let middleIndex = Math.floor(sortedArray.length / 2)

  let leftArray = sortedArray.splice(0, middleIndex)
  let rightArray = sortedArray

  leftArray = mergeSort(leftArray)
  rightArray = mergeSort(rightArray)

  return merge(leftArray, rightArray)
}

function merge(leftArray, rightArray) {
  let mergedArray = []

  while(leftArray.length > 0 && rightArray.length > 0) {
    if (leftArray[0] > rightArray[0]) {
      mergedArray.push(rightArray.shift())
    } else {
      mergedArray.push(leftArray.shift())
    }
  }

  if (leftArray.length > 0) {
    mergedArray = [...mergedArray, ...leftArray]
  }
  if (rightArray.length > 0) {
    mergedArray = [...mergedArray, ...rightArray]
  }

  return mergedArray
}

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