object Main extends App {
  val sc = new java.util.Scanner(System.in) 
  sc.useDelimiter("\n")
  val n = sc.nextInt()
  val a = sc.next().split(' ').map(_.toInt).toList.sortBy(- _)
  var alice = for((x, i) <- a.zipWithIndex if i % 2 == 0) yield x
  var bob = for((x, i) <- a.zipWithIndex if i % 2 != 0) yield x
  println(alice.sum - bob.sum)
  
}