fun main(args: Array<String>) {
    val n= readLine()!!.toInt()
    var a = readLine()!!.split(" ").map{i -> i.toInt()}.sorted().reversed()
    var alice = 0
    var bob = 0

    for( i in 0..n-1){
        if(i % 2 == 0) alice += a[i] else bob += a[i]
    }
    println(alice - bob)
}