import scala.io.StdIn._

object Main {
    def main(args: Array[String]): Unit = {
        readLine
        var a = 0
        var b = 0
        readLine.split(" ").map(_.toInt).sorted.zipWithIndex.foreach { (x) =>
            x._2 % 2 match {
                case 0 => a += x._1
                case 1 => b += x._1
            }
        }
        println(scala.math.abs(a - b))
    }
}