local n = io.read("*n")
local a = {}
for i = 1, n do
    a[i] = io.read("*n")
end

local alice_sum, bob_sum = 0, 0
table.sort(a, function(x, y) return x > y end)
for i = 1, n do
    if i % 2 == 1 then
        alice_sum = alice_sum + a[i]
    else
        bob_sum   = bob_sum   + a[i]
    end
end

print(alice_sum - bob_sum)