import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val all: MutableList<Int> = mutableListOf()
    for (i in 0 until n) {
        all.add(sc.nextInt())
    }
    var a = 0
    var b = 0
    for (i in 0 until n) {
        val max = all.max()!!.toInt()
        if (i % 2 == 0) {
            a += max
        } else {
            b += max
        }
        all.remove(max)
    }
    if (a >= b) {
        println(a - b)
    } else {
        println(b - a)
    }
}