# ABC088B - Card Game for Two

n = int(eval(input()))

lst = sorted(list(map(int, input().rstrip().split())), reverse=True)

total = 0

for i in range(n):

    if i % 2 == 0:

        total += lst[i]

    else:

        total -= lst[i]

print(total)
# ABC088B - Card Game for Two

import sys

input = sys.stdin.readline



n = int(eval(input()))

lst = sorted(list(map(int, input().rstrip().split())), reverse=True)

total = 0

for i in range(n):

    if i % 2 == 0:

        total += lst[i]

    else:

        total -= lst[i]

print(total)
# ABC088B - Card Game for Two
n = int(eval(input()))
lst = sorted(list(map(int, input().rstrip().split())), reverse=True)
total = 0
for i in range(n):
    if i % 2 == 0:
        total += lst[i]
    else:
        total -= lst[i]
print(total)

# ABC088B - Card Game for Two
import sys

input = sys.stdin.readline
n = int(eval(input()))
lst = sorted(list(map(int, input().rstrip().split())), reverse=True)
total = 0
for i in range(n):
    if i % 2 == 0:
        total += lst[i]
    else:
        total -= lst[i]
print(total)

+import sys + +input = sys.stdin.readline