import kotlin.math.absoluteValue

fun main() {
    readLine()
    readLine()!!.split(" ").asSequence().map(String::toInt).sortedDescending()
            .mapIndexed { index, i ->  index to i }
            .groupBy { it.first.rem(2) == 0 }
            .map { e ->
                e.value.sumBy { it.second }
            }.reduce { alice, bob ->
                (alice - bob).absoluteValue
            }.let {
                println(it)
            }
}
