function Main(input) {
	input = input.split("\n");
  var card = input[1].split(" ");
  var alice = 0;
  var bob = 0;
  var turn = 0;
  card = card.map((a)=>Number(a));
  function p(card){
    if(turn==0){
      alice+=Math.max.apply(null,card);
      turn=1;
    }else{
      bob+=Math.max.apply(null,card);
      turn=0;
    }
    card.splice(card.indexOf(Math.max.apply(null,card)),1);
    if(card==''){
      console.log(alice-bob);
    }else{
      return p(card);
    }
  }
  p(card);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));