fun main(args: Array<String>) {

    var n = readLine()!!.toInt()
    var input = readLine()!!.split(" ").map { it.toInt() }

    var inputSorted = input.sortedDescending()

    var a = 0
    var b = 0
    for (i in 0..(n-1)) {
        if (i%2 == 1) a += inputSorted[i] else b += inputSorted[i]
    }
    var diff = a - b

    if (diff == 0) print(diff) else print(-1 * diff)
}