import scala.io.StdIn
object Main extends App {
  val N = StdIn.readLine().toInt
  val cards = StdIn.readLine().split(" ").map(_.toInt).toList.sorted.reverse
  val aliceCards = for {
    i <- 0 until N
    if (i % 2 == 0)
  } yield cards(i)
  val bobCards = for {
    i <- 0 until N
    if (i % 2 == 1)
  } yield cards(i)
  println(aliceCards.sum - bobCards.sum)
}
