    fun main(args: Array<String>) {
        val input = read()
        println(cardGameForTwo(input))
    }

    data class Inputs(val count: Int, val cards: List<Int>)

    fun read(): Inputs {
        return Inputs(
            Integer.parseInt(readLine()!!),
            readLine()!!.split(' ').map { Integer.parseInt(it) }
        )
    }

    fun cardGameForTwo(inputs: Inputs): Int {
        val sorted = inputs.cards.sortedDescending()

        val alice = sorted.withIndex().sumBy { if (it.index % 2 == 0) it.value else 0 }
        val bob = sorted.withIndex().sumBy { if (it.index % 2 == 1) it.value else 0 }
        return alice - bob
    }