object Main extends App{
val n = scala.io.StdIn.readInt()
val as = scala.io.StdIn.readLine().split("\\s").map(_.toInt).sortBy(_ * -1)

var cnt = 0
for (i <- 0 until as.length) {
  if (i%2==0) cnt += as(i) else cnt -= as(i)
}
println(cnt)
}