function Main(input) {
    var n = input.split("\n")[0];
    var stringNums = input.split("\n")[1].split(" ");
    var nums = [];
    var alice = 0;
    var bob = 0;

    for(var i = 0; i < n; i++ ) {
        nums.push(Number(stringNums[i]));
    }
    
    nums.sort(
        function(a,b){
          return b - a
        }
      );
      

    for (var i = 0; i < n ; i++) {
        if (i % 2 === 0 ){
            alice = alice + nums[i];
        } else {
            bob = bob + nums[i]
        }
    }
    console.log(alice - bob);
  
    }
  Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  