N = int(input())
a = [int(c) for c in input().split(" ")]

alice = 0
bob = 0
for i, ai in enumerate(sorted(a, reverse=True)):
    if i % 2 == 0:
        alice += ai
    else:
        bob += ai
ans = alice - bob

print(ans)
