import scala.io.StdIn

object Main extends App {
  val n = StdIn.readLine
  val ans = StdIn.readLine.split(" ").map(_.toInt)
    .sortWith( _ > _ ).par
    .zipWithIndex.map(e => if ((e._2 & 1) == 0) e._1 else -e._1)
    .sum

  println(ans)
}
