fun main(args: Array<String>) {
    abc088b()
}

fun abc088b() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(" ").map { it.toInt() }
        .sortedDescending().mapIndexed { index, i -> Pair(index, i) }

    val (a, b) = aList.partition { it.first % 2 == 0 }

    val answer = a.map { it.second }.sum() - b.map { it.second }.sum()

    println(answer)
}
