object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  var list = List.fill(n)(sc.nextInt)

  var aliceSum = 0
  var bobSum = 0
  list.sorted.reverse.zipWithIndex.foreach{
    v =>
      if(v._2 % 2 == 0) aliceSum += v._1
      else bobSum += v._1
  }

  println(aliceSum - bobSum)
}