import scala.io.StdIn

object Main extends App {
  val counts = StdIn.readInt()
  val cards = StdIn.readLine().split(" ").map(_.toInt).sortWith(_ > _)

  val alicesScore = Iterator.from(0, 2).takeWhile(_ < cards.length).map(cards(_)).sum
  val bobsScore = Iterator.from(1, 2).takeWhile(_ < cards.length).map(cards(_)).sum

  val ans = alicesScore - bobsScore
  println(ans)
}
