object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val a = List.fill(n)(sc.nextInt()).sorted.reverse
  val ans = a.sliding(1, 2).flatten.sum - a.tail.sliding(1, 2).flatten.sum
  println(ans)
}
