import java.util.Scanner

import scala.collection.mutable.ArrayBuffer

object Main extends App {

  val sc = new Scanner(System.in)
  val n = sc.nextInt()
  sc.nextLine()
  val a = sc.nextLine().split(" ").map(_.toInt)

  val Alice = ArrayBuffer.empty[Int]
  val Bob = ArrayBuffer.empty[Int]

  a.sorted.reverse.foreach {
    an => if (Alice.length > Bob.length) Bob += an else Alice += an
  }

  println(Alice.sum - Bob.sum)

}
