import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val N = sc.nextInt
  val a = Array.fill(N)(sc.nextInt).sorted.reverse

  val x = (0 until N by 2).map(a(_)).sum
  val y = (1 until N by 2).map(a(_)).sum
  val z = x - y
  println(z)
}
