import scala.io.StdIn

object Main {
  def main(args: Array[String]): Unit = {
    val n = StdIn.readInt
    val array = StdIn.readLine.split(" ").map(_.toInt)
    val arr = array.sortWith(_ > _)
    var bob = 0
    var alice = 0
    for(a <- 0 to arr.length -1) if(a % 2 == 0) alice += arr(a) else bob += arr(a)
    println(alice - bob)
    
  }
  
}