'use strict'

function Main(input) {
  const inputList = input.split('\n');
  const n = inputList[0]
  const numberStringList = inputList[1].split(' ')
  let numberList = []
  numberList = numberStringList.map((numberString) => Number(numberString))
  
  const sortedNumberList = numberList.sort(function(a, b){return b-a});

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

  const result = aliceTotal - bobTotal

  console.log(result)
}


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