"""abc088_b"""

N = int(eval(input()))

A = list(map(int, input().split()))



alice = 0

bob = 0



a_desc = sorted(A, reverse=True)



for i, a in enumerate(a_desc):

    if i % 2 == 0:

        alice += a

    else:

        bob += a



print((alice - bob))

"""abc088_b"""

N = int(eval(input()))

A = list(map(int, input().split()))



a_desc = sorted(A, reverse=True)

print((sum(a_desc[0::2])-sum(a_desc[1::2])))

"""abc088_b"""
N = int(eval(input()))
A = list(map(int, input().split()))
alice = 0
bob = 0
a_desc = sorted(A, reverse=True)
for i, a in enumerate(a_desc):
    if i % 2 == 0:
        alice += a
    else:
        bob += a
print((alice - bob))

"""abc088_b"""
N = int(eval(input()))
A = list(map(int, input().split()))
a_desc = sorted(A, reverse=True)
print((sum(a_desc[0::2]) - sum(a_desc[1::2])))

-alice = 0 -bob = 0 -for i, a in enumerate(a_desc): -    if i % 2 == 0: -        alice += a -    else: -        bob += a -print((alice - bob)) +print((sum(a_desc[0::2]) - sum(a_desc[1::2])))