"use strict"
function Main(input) {
  input = input.trim().split('\n');
  const N = input[0];
  const A = input[1].trim().split(' ').map(Number).sort((a,b) => b-a);

  let a = 0;
  let b = 0;
  for(let i=0; i<N; i++){
    if(i % 2 === 0){
      a += A[i];
    } else {
      b += A[i];
    }
  }

  console.log(a-b);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));