import scala.io.StdIn

object Main extends App {
   val n = StdIn.readLine().toInt
   val a = StdIn.readLine().split(' ').map(_.toInt).sorted(Ordering[Int].reverse).zipWithIndex

   //println(a.mkString(" "))
   println(a.foldLeft(0)((acc, p) => if(p._2 % 2 == 0) acc + p._1 else acc - p._1))
}
