object Main {
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val as = List.fill(n)(sc.nextInt)

    print {
      val bs = {if (as.length%2 == 0) as else 0 :: as}
        .sorted
        .grouped(2).toList
      bs.map(_(1)).sum - bs.map(_(0)).sum
    }
  }
}
