fun main(args: Array<String>) = println(run {
    val n = readLine()!!
    val a = readLine()!!.split(" ").map { it.toInt() }.sortedDescending()

    a.slice(a.indices step 2).sum() - a.slice((1..a.lastIndex) step 2).sum()

})
