fun main(array: Array<String>) {
    val n = readLine()!!.toInt()
    val x = readLine()!!.split(" ").map { it.toInt() }.sorted().reversed()
    var a = 0
    var b = 0
    repeat(n) {
        if(it % 2 === 0) {
            a += x[it]
        }
        else {
            b += x[it]
        }
    }
    print(a - b)
}