function main(input){
    args = input.split("\n");
    n = args[0]
    a = args[1].split(" ").map((n)=>parseInt(n, 10))
    a.sort(function(a,b){return (a < b)? 1:-1})
    c = 0;
    for (var i=0; i < a.length - 1 ; i+=2){
        c+= a[i] - a[i+1] 
    }
    console.log(c);

}
main(require('fs').readFileSync('/dev/stdin', {encoding:'utf8'}))
