
fun main(args: Array<String>) {
    val n = readInt()
    val a = readIntList().sorted().reversed()
    val bob = (1 until n step 2).sumBy { a[it] }
    val alice = (0 until n step 2).sumBy { a[it] }
    println(alice - bob)
}

fun readIntList(): List<Int> = readLine()!!.split(' ').map { it.toInt() }

fun readInt(): Int = readLine()!!.toInt()

fun err(print: Any) {
    System.err.println(print)
}