"use strict"

const Main = (nyuuryoku)=>{
const Array=nyuuryoku.split(/\n/)
const N=Array[0]-0
const cardNumber=Array[1].split(" ").map((ele)=>{return ele-0}).sort((a,b)=>{return b-a})

let AliceScore=0
let BobScore=0

for(let i=0;i<=cardNumber.length-1;i+=1){
 (i%2==0)?  AliceScore+=cardNumber[i] : BobScore+=cardNumber[i] 
 }

console.log(AliceScore - BobScore)
}

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