object Main{
  def main(args: Array[String]) {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val list = Seq.fill(n)(sc.nextInt)

    val (alice, bob) = list.
      sorted(Ordering[Int].reverse).
      zipWithIndex.
      foldLeft{ (Seq.empty[Int], Seq.empty[Int]) } {
        case ((alice, bob), (a, i)) => i match {
          case i if i % 2 == 0 => (alice :+ a, bob)
          case _ => (alice, bob :+ a)
        }
      }
    println(sum(alice) - sum(bob))

    def sum(xs: Seq[Int]): Int = xs.foldLeft(0)(_ + _)
  }
}