import scala.io.StdIn

object Main extends App {
  val n = StdIn.readLine
  val ans = StdIn.readLine.split(" ").map(_.toInt)
    .sorted(Ordering[Int].reverse)
    .zipWithIndex
    .foldLeft(0){ (acc,e) =>
      acc + ( if((e._2 & 1) == 0) e._1 else -e._1 )
    }

  println(ans)
}
