import java.util.*

val sc = Scanner(System.`in`)
val N = sc.nextInt()

fun main(args: Array<String>) {
    val a = Array(N) { sc.nextInt() }
    a.sortDescending()
    println(a.mapIndexed { i, v -> pow(-1, i) * v }.sum())
}

fun pow(a: Int, b: Int): Int {
    var result = 1
    repeat(b) {
        result *= a
    }
    return result
}
