function Main(input){
	input = input.split("\n");
  var arr = input[1].split(" ").map(Number);
  arr = arr.sort(function(a,b){return a-b;});
  var n=0,m=0;
  for(var i=0;i<arr.length;i++){
    if(i%2==0){
      n += arr[i];
    }else{
      m += arr[i];
    }
  }
  console.log(m-n);
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());