import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val as = List.fill(n)(sc.nextInt())
    var ans = 0
    for (i <- as.sorted.reverse.indices) {
      if (i % 2 == 0) {
        ans += as(i)
      } else {
        ans -= as(i)
      }
    }

    println(ans)
  }
}
