Felix6326727/beyond-accuracy-code-comprehension huggingface dataset:
n = int(input())
l = sorted(list(map(int, input().split())), reverse = True)
ali = 0
bob = 0
if n % 2 == 1:
    ali = l[n-1]
for i in range(n//2):
    ali += l[i*2]
    bob += l[i*2+1]
print(ali - bob)


# Example run
# Input:
-69520
-73864104
# Output:
0
n=int(input())
a=[int(i) for i in input().split()]
a.sort(reverse=True)
b=0
c=0
if n%2==0:
    for i in range(n//2):
        b+=a[2*i]
        c+=a[2*i+1]
else:
    for i in range(n//2):
        b+=a[2*i]
        c+=a[2*i+1]
    b+=a[n]
if b>c:
    print(b-c)
else:
    print(c-a)


# Example run
# Input:
-1
60
# Output:
60
N = int(input())
A = sorted(list(map(int, input().split())))

Alice_sum = 0
Bob_sum = 0

if N % 2 == 0:
    Alice_sum = sum(A[1::2])
    Bob_sum = sum(A[0::2])
else:
    Alice_sum = sum(A[0::2])
    Bob_sum = sum(A[1::2])

result = Alice_sum - Bob_sum

print(result)

# Example run
# Input:
1363926
77305
# Output:
-77305
n=int(input())
a=sorted(list(map(int,input().split())),reverse=True)
ali=0
bob=0
for i in range(len(a)):
  if i%2==0:
    ali+=a[i]
  else:
    bob+=a[i]
print(ali-bob)

# Example run
# Input:
31
-5
# Output:
-5
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
alice = 0
bob = 0
for i in range(N):
  if i % 2 == 0:
    alice += a[i]
  else:
    bob += a[i]
print(alice - bob)


# Example run
# Input:
-572
3
# Output:
0
N=int(input())
a = list(map(int,input().split()))

a.sort(reverse=True)
alice=0
bob=0
tf=True
for i in a:
    if tf:
        alice+=i
    else:
        bob+=i
    tf=not tf
print(alice-bob)


# Example run
# Input:
-2540
-1836
# Output:
-1836
n = int(input())

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

Ai.sort(reverse = True)


ans = 0
for i in range(n):
    
    ans += Ai[i] * (1 if i%2== 0 else -1)
    
print(ans)

# Example run
# Input:
-331
18
# Output:
0
def ret_max(n, list):
    i = 0
    tmp = 0
    max = 0
    for i in range(n):
        if(max < list[i]):
            tmp = i
            max = list[i]
    return tmp

N = int(input())
lis = [int(i) for i in input().split()]

j = 0
k = 0
alice = 0
bob = 0
max = 0
lis_elem = len(lis)

for j in range(N):
    lis_elem = len(lis)
    max = lis[ret_max(lis_elem, lis)]
    print("max:",max)
    del lis[ret_max(lis_elem, lis)]
    if(j%2 == 0):
        alice = alice + max
    elif(j%2 == 1):
        bob = bob + max

print(alice - bob)


# Example run
# Input:
-10081
-233
# Output:
0
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

N = int(input())
a = readints()
# print(a)
aa = sorted(a, reverse=True)
# print(aa)
x = 0
for i in range(len(a)):
    if i % 2 == 0:
        x += aa[i]
    else:
        x -= aa[i]
print(x)


# Example run
# Input:
-30
119
# Output:
119
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

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

A.sort(reverse=True)

alice = 0 
bob = 0
for i, a in enumerate(A):
    if i % 2 == 0:
        alice += a
    else:
        bob += a

ans = alice - bob
print(ans)

# Example run
# Input:
9005859
23263394
# Output:
23263394
n = int(input())
a = list(map(int,input().split()))
a.sort()
if n % 2 == 0:
  A = sum(a[1::2])
  B = sum(a[::2])
else:
  A = sum(a[::2])
  B = sum(a[1::2])

print(A-B)

# Example run
# Input:
25627025
-53605951
# Output:
-53605951
n = input()
a = list(map(int, input().split()))
a.sort(reverse=True)

alice = 0
bob = 0

for i in range(len(a)):
    if (i // 2) == 0:
        alice += a[i]
    else:
        bob += a[i]

print(alice - bob)

# Example run
# Input:
.SD+<
-426204934
# Output:
-426204934
n = input()
a = list(map(int, input().split()))
a_sort = sorted(a, reverse=True)

score = 0
for i, j in enumerate(a_sort):
    if i % 2 == 0:
        score += j
    else:
        score -= j

print(score)

# Example run
# Input:
AkU({
1049999
# Output:
1049999
N = int(input())
A = map(int, input().split())
B = list(A)
B.sort()
B.reverse()
Alice = 0
Bob = 0
for i in range(N):
    if i % 2 == 0:
        Alice += B[i]
    else:
        Bob += B[i]
print(Alice - Bob)

# Example run
# Input:
-686
15761764
# Output:
0
# https://atcoder.jp/contests/abc088/tasks/abc088_b
n = input().split()[0]
a_list = list(map(int, input().split()))

alice_list = []
bob_list = []
sorted(a_list)

for i in range(len(a_list)):
    max_a = max(a_list)
    a_list.remove(max_a)

    if i % 2 == 0:
        alice_list.append(max_a)
    else:
        bob_list.append(max_a)

answer = sum(alice_list) - sum(bob_list)
print(answer)

# Example run
# Input:
)jy
-87
# Output:
-87
import math
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
Alice = []
Bob = []
for i in range (N):
  if i % 2 == 0:
    Alice.append(a[i])
  else:
    Bob.append(a[i])
print(sum(Alice)-sum(Bob))


# Example run
# Input:
-1377730
25086089
# Output:
0
N = input()
a = input().split()
a = list(map(int, a))

a.sort()
a.reverse()

alice = 0
bob = 0

a_num = len(a)

for i in range(a_num):
  if i % 2 == 0:
    alice += int(a[i])
  else:
    bob += int(a[i])

print(alice - bob)




# Example run
# Input:
;RvkF,
40
# Output:
40
n = int(input())
a = list(map(int, input().split()))
a.sort()
print(abs(sum(a[0::2]) - sum(a[1::2])))


# Example run
# Input:
-83
0
# Output:
0
N = input()
cards = list(map(int, input().split()))
cards = sorted(cards)[::-1]
print(sum(cards[0::2]) - sum(cards[1::2]))


# Example run
# Input:
&*/EU;}#
-957592179
# Output:
-957592179
n = int(input())
AS = list(map(int,input().split()))
AS.sort()
AS.reverse()
print(sum(AS[::2]) - sum(AS[1::2]))

# Example run
# Input:
-83
-39355
# Output:
-39355
def getInput():
    return [int(i) for i in input().rstrip().split(' ')]

N = getInput()[0];
a_i = getInput()
ret = 0

for i in range(1, N+1):
    if not i % 2 == 0:
        ret += a_i.pop(a_i.index(max(a_i)))
    else:
        ret -= a_i.pop(a_i.index(max(a_i)))
print(ret)

# Example run
# Input:
-2
-99110661
# Output:
0
n = int(input())
A = tuple(map(int, input().split()))
A = sorted(A, reverse=True)

alice = sum(A[0::2])
bob = sum(A[1::2])
print(alice - bob)



# Example run
# Input:
-24
-1477
# Output:
-1477
input()
a = sorted(map(int, input().split()))[::-1]
print(sum(a[::2])-sum(a[1::2]))

# Example run
# Input:
(s?
-145
# Output:
-145
n = int(input())
A = sorted(list(map(int, input().split())), reverse=True)

alice, bob = 0, 0
for i in range(n):
    if i % 2 == 0:
        alice += A[i]
    else:
        bob += A[i]

print(abs(alice - bob))

# Example run
# Input:
-64990941
-12142
# Output:
0
n = int(input())
a = [int(x) for x in input().split()]
sortA = sorted(a, reverse=True)
Alice = 0
Bob = 0
for i in range(len(a)):
    if i % 2 == 0:
        Alice+=sortA[i]
    else:
        Bob+=sortA[i]
    
print(Alice - Bob)

# Example run
# Input:
-1
-3439167
# Output:
-3439167
n = int(input())
a = list(map(int, input().split()))

if n%2 != 0:
  a.append(0)
  n += 1
 
a.sort()
d = 0

for i in range(int(n/2)):
               d += a[2*i+1]-a[2*i]
           
print(d)


# Example run
# Input:
-1043639
-2556
# Output:
0
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    n=int(input())
    A=list(map(int,input().split()))
    A.sort(reverse=True)
    val=0
    for i in range(n):
        if i%2==0:
            val+=A[i]
        else:
            val-=A[i]

    print(val)



resolve()

# Example run
# Input:
-75
57223618
# Output:
0
times = int(input())
ans = 0
type = 1
num = list(map(int,input().split(" ")))
num.sort(reverse=True)
for i in num:
    if type % 2:
        ans += i
    else:
        ans -= i
    type += 1
    
print(ans)

# Example run
# Input:
981571
-6163826
# Output:
-6163826
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
Alice = []
Bob = []
for i in range(N):
  if i%2 == 0:
    Alice.append(A[i])
  else:
    Bob.append(A[i])

print(sum(Alice) - sum(Bob))

# Example run
# Input:
-118998188
-337
# Output:
0
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)

alice = sum(a[::2])
bob = sum(a[1::2])
print(alice-bob)

# Example run
# Input:
20794
14319043
# Output:
14319043
input()
numbers = list(map(lambda x: int(x), input().split(" ")))
numbers.sort(reverse=True)
alice = 0
bob = 0
isAlice = True;
for number in numbers:
    if isAlice:
        alice += number
        isAlice = False
    else:
        bob += number
        isAlice = True

print(alice - bob)

# Example run
# Input:
;RvkF,}Eo
61186
# Output:
61186
n = int(input())
a = list(map(int,input().split()))
a = sorted(a, reverse=True)
A,B = 0,0
for i in range(n):
    if i % 2 == 0:
        A += a[i]
    else:
        B += a[i]
print(A-B)

# Example run
# Input:
-2147483648
-15824
# Output:
0
input()
a = sorted(map(int, input().split()))[::-1]
print(sum(a[::2])-sum(a[1::2]))

# Example run
# Input:
8r+|E
51856
# Output:
51856
n = int(input())
a = input().split()

a = list(map(int, a))

alice_n = a[::2]
bob_n = a[1::2]

print(sum(alice_n) - sum(bob_n))

# Example run
# Input:
-1
-3439167
# Output:
-3439167
n = int(input())
a_list = sorted(list(map(int,input().split())),reverse=True)
print(sum(a_list[::2])-sum(a_list[1::2]))

# Example run
# Input:
-1
-3439167
# Output:
-3439167
_ = input()
a = input().split()

ans = 0
bob = []
alice = []
a = sorted(a, reverse=True)
for i, card in enumerate(a):
    if i%2 == 0:
        alice.append(int(card))
    else:
        bob.append(int(card))

ans = (sum(alice)-sum(bob))
print(ans)

# Example run
# Input:
Lg*
-1415818695
# Output:
-1415818695
data = [input() for x in range(0, 2, 1)]

cards = [int(x) for x in data[1].split(" ")]

#バブルソート
for i in range(0, len(cards), 1):
  
  for j in range(i + 1, len(cards), 1):
    
    if cards[i] < cards[j]:
      tmp1 = cards[i]
      tmp2 = cards[j]
      
      cards[i] = tmp2
      cards[j] = tmp1
      
alice = 0
bob = 0

#cardsをソート

for i, v in enumerate(cards):
  
  if i %2 == 0:
    alice += v
  else:
    bob += v
    
print(alice - bob)


# Example run
# Input:
WyDwtf}o
-6212597
# Output:
-6212597
n = int(input())
nums = [int(x) for x in input().split()]
nums.sort(reverse=True)
print(sum(nums[::2]) - sum(nums[1::2]))

# Example run
# Input:
11
-40
# Output:
-40
N = int(input())
a = list(map(int, input().split()))
b = sorted(a)[:: -1]
print(sum(b[:: 2]) - sum(a[1:: 2]))


# Example run
# Input:
-117864
-38181262
# Output:
-38181262
n = int(input())
a_list = list(map(int, input().split()))
a_list = sorted(a_list, reverse=True)
alice_point = sum(a_list[::2])
bob_point = sum(a_list[1::2])
print(alice_point-bob_point)

# Example run
# Input:
9
1648
# Output:
1648
# -coding: utf-8 -

n = int(input())
a =list(map(int, input().split()))

a = sorted(a, reverse = True)

#print(a)

alice = 0
for i in range(len(a)):
    if i%2 == 0:
        alice += a[i]

#print(alice)

bob = sum(a) - alice

print(alice - bob)
        




# Example run
# Input:
713362851
133233772
# Output:
133233772
n = int(input())
l = list(map(int,input().split()))
l.sort(reverse=True)
num = 0
num1 = 0
for i in range(n):
  if i % 2 == 0:
    num += l[i]
  else:
    num1 += l[i]
print(num-num1)

# Example run
# Input:
0
456
# Output:
0
N=int(input())
a=list(map(int,input().split()))

#ai=a[i-1]とした
A=0
S=0
a.sort(reverse=True)
for i in range(N):
    S+=a[i]
    if i%2==0:
        A+=a[i]
print(abs(S-2*A))


# Example run
# Input:
-436344399
-83
# Output:
0
N = int(input())
aList = list(map(int, input().split()))
aList.sort(reverse = True)
aPoint = 0
bPoint = 0
if N % 2 == 0:
    for i in range(N//2):
        aPoint += aList[2*i]
        bPoint += aList[2*i + 1]
else:
    for i in range(N//2):
        aPoint += aList[2*i]
        bPoint += aList[2*i + 1]
    aPoint += aList[N-1]
print(aPoint - bPoint)

# Example run
# Input:
-2552
-330190783
# Output:
0
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
print(sum(A[::2])-sum(A[1::2]))


# Example run
# Input:
2147483647
-3
# Output:
-3
n=int(input())
a=[int(x) for x in input().split()]
al=0
bo=0
a.sort()
for i in range(n):
  if i%2==0:
    al+=a[-i-1]
  else:
    bo+=a[-i-1]
print(al-bo)

# Example run
# Input:
1
-124978655
# Output:
-124978655
N = int(input())
l = list(map(int, input().split()))
a = 0
b = 0
l.sort(reverse = True)

for i in range(N):
    if i % 2 == 0:
        a += l[i]
    else:
        b += l[i]
print(a-b)

# Example run
# Input:
-8056
-449705
# Output:
0
N = int(input())
A = sorted(list(map(int,input().split())))[::-1]
print(sum(A[0::2])-sum(A[1::2]))

# Example run
# Input:
3374754
3132478
# Output:
3132478
f = lambda :[int(i) for i in input().split()]

N = int(input())
a = f()

a.sort()
alice = 0
bob = 0
while a:
    alice += a.pop()
    if not(a):
        break
    bob += a.pop()
print(alice - bob)

# Example run
# Input:
-247
-12142
# Output:
-12142
N = int(input())
a = sorted(list(map(int, input().split())))

A = 0
B = 0
i = 0
while len(a) > 0:
    if i % 2 == 0:
        A += a.pop()
    else:
        B += a.pop()
    i += 1
print(A - B)


# Example run
# Input:
629110165
-2147483648
# Output:
-2147483648
n=int(input())
a=list(map(int, input().split()))
a.sort(reverse=True)
Alice=sum(a[0::2])
Bob=sum(a[1::2])
print(Alice-Bob)

# Example run
# Input:
-9
-13574883
# Output:
-13574883
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
print(sum(A[0::2])-sum(A[1::2]))

# Example run
# Input:
-84521052
-2
# Output:
-2
n = int(input())
a = list(map(int, input().split(" ")))
alice = []
bob = []
a.sort(reverse=True)
for k in range(int(n / 2) + 1):
    try:
        alice.append(a[2 * k])
        bob.append(a[2 * k + 1])
    except:
        pass
al = sum(alice)
bo = sum(bob)
res = abs(al - bo)
print(res)


# Example run
# Input:
3
-264371717
# Output:
264371717
n = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
alice = 0
bob = 0
for i in range(n):
    if i % 2 == 0:
        alice += a[i]
    else:
        bob += a[i]
print(abs(alice - bob))


# Example run
# Input:
-124978655
-23909
# Output:
0
N = int(input())
ls = list(map(int, input().split()))
alice = 0
bob = 0

for i in range(N):
    if((i % 2) == 0):
        alice += max(ls)
    else:
        bob += max(ls)
    ls[ls.index(max(ls))] = 0

out = alice - bob
print(out)


# Example run
# Input:
-9486
-1394868732
# Output:
0
N=int(input())
alise=0
bob=0
a_list=list(map(int,input().split()))
a_sort=sorted(a_list)
for i in range(N,0,-2):
    alise+=a_sort[i-1]
for i in range(N-1,0,-2):
    bob+=a_sort[i-1]
print(alise-bob)


# Example run
# Input:
-62350830
260615611
# Output:
0
N = int(input())
A = sorted(list(map(int,input().split())))
print(abs(sum(A[::2]) - sum(A[1::2])))

# Example run
# Input:
-4953150
3320259
# Output:
3320259
N=int(input())
an=map(int,input().split())
Cards=[]
for a in an:
    Cards.append(int(a))
SortedCards=sorted(Cards,reverse=True)
AliceCards=SortedCards[0::2]
BobsCards=SortedCards[1::2]
print(sum(AliceCards)-sum(BobsCards))

# Example run
# Input:
-2123
-9018239
# Output:
-9018239
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
print(sum(a[::2]) - sum(a[1::2]))

# Example run
# Input:
-5930
-31
# Output:
-31
def myAnswer(N:int,A:list) -> int:
   Alice = 0
   Bob = 0
   A.sort(reverse=True)
   for n,a in enumerate(A):
      if (n%2 == 0):
         Alice += a
      else:
         Bob += a
   return Alice - Bob

def modelAnswer():
   tmp=1
def main():
   N = int(input())
   A = list(map(int,input().split()))
   print(myAnswer(N,A[:]))

if __name__ == '__main__':
   main()

# Example run
# Input:
43064
-3108573
# Output:
-3108573
N = int(input())
lines = input().split(' ')
lines = [int(x) for x in lines]
a_list = sorted(lines)
A = 0
B = 0


while len(a_list) > 0:
	A += a_list.pop()
	if len(a_list) > 0:
		B += a_list.pop()

print(A - B)

# Example run
# Input:
1510792572
-224960337
# Output:
-224960337
def main():
    n = int(input())
    a = list(map(int, input().split()))
    alice, bob = 0, 0
    a = sorted(a)
    for i, x in enumerate(a[::-1]):
        if i % 2 == 0:
            alice += x
        else:
            bob += x
    print(alice - bob)


if __name__ == "__main__":
    main()


# Example run
# Input:
493
471
# Output:
471
N=int(input())
a=list(map(int, input().split()))

a=sorted(a, reverse=True)
A=[]
B=[]

for i in range(N):
    if i%2==0:
        A.append(a[i])
    else:
        B.append(a[i])

print(sum(A)-sum(B))

# Example run
# Input:
-178
-242773652
# Output:
0
N=int(input())

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

a.sort(reverse=True)
A=[]
B=[]

for i,k in enumerate(a):
    if i%2 == 0:
        A.append(a[i])
               
               
    elif i%2 == 1:
        B.append(a[i])
        
    print(i)    
print(sum(A)-sum(B))  

# Example run
# Input:
-69520
-73864104
# Output:
0
-73864104
n = int(input())
a = list(input().split())

a.sort(reverse=True)

alice = 0
bob = 0

for i in range(len(a)):
    if i % 2 == 0:
        alice = alice + int(a[i])
    else:
        bob = bob + int(a[i])

print (alice-bob)


# Example run
# Input:
2569
30315
# Output:
30315
n=int(input())
a=list(map(int,input().split()))
ans=0
a.sort()

while n>0:
  ans+=a[n-1]
  n-=1
  if n==0:
    break
  ans-=a[n-1]
  n-=1
  
print(ans)

# Example run
# Input:
1
-224484380
# Output:
-224484380
N = int(input())
a = list(map(int,input().split()))
a_sort = sorted(a,reverse=True)
ans = sum(a_sort[::2]) - sum(a_sort[1::2])
print(ans)


# Example run
# Input:
-1018584
-247
# Output:
-247
N = int(input())
a = list(map(int, input().split()))

alice = 0
bob = 0

for n in range(N):
    if len(a) == 0:
        break
    card = max(a)
    alice += card
    a.remove(card)
    if len(a) == 0:
        break
    card = max(a)
    bob += card
    a.remove(card)

print(alice - bob)

# Example run
# Input:
274829
21
# Output:
21
# -*- coding: utf-8 -*-

n = int(input())

l_a = sorted(map(int, input().split()), reverse=True)

print(sum([((-1)**(i%2))*a for i, a in enumerate(l_a)]))


# Example run
# Input:
1648
107
# Output:
107
num = int(input())
cards = sorted(list(map(int, input().split())), reverse = True)
alice = 0
bob = 0

for i in range(num):
  if i//2*2 == i:
    alice += cards[i]
  else:
    bob += cards[i]

print(alice - bob)

# Example run
# Input:
-959568
-377
# Output:
0
N = int(input())
if N == 1:
  print(input())
else:
  A = 0
  B = 0
  a = list(map(int,input().split()))
  a.sort()
  a.reverse()
  for i in range(N):
    if i % 2 == 0:
      A += a[i]
    else:
      B += a[i]
  print(A - B)

# Example run
# Input:
-7698469
-5952
# Output:
0
n = int(input())
a = list(map(int, input().split()))
a.sort()
a.reverse()

alice = sum([a[i] for i in range(len(a)) if i % 2 == 0])
bob = sum([a[i] for i in range(len(a)) if i % 2 != 0])
print(alice-bob)

# Example run
# Input:
4887419
815520
# Output:
815520
n = int(input())
a = [int(x) for x in input().split()]
res = 0
for i in range(n):
  if n % 2 == 0:
    res += a[i]
  else:
    res -= a[i]
print(res)

# Example run
# Input:
-84559984
-58783
# Output:
0
N = int(input())
a = map(int, input().split())
list = sorted(a, reverse = True)
Alice = sum(list[0:N:2])
Bob = sum(list[1:N:2])
print(Alice - Bob)

# Example run
# Input:
3485
17754
# Output:
17754
n = int(input())
card_list = [int(x) for x in input().split()]

countA = 0
countB = 0

card_list.sort()
card_list.reverse()


for i, x in enumerate(card_list):
    if i % 2 == 0:
        countA += x
    else :
        countB += x
        
print(countA - countB)

# Example run
# Input:
-132894
-7798
# Output:
-7798
input()
cards = sorted([int(x) for x in input().split()], reverse = True)
alice_point = sum([x for i, x in enumerate(cards) if i % 2 == 0])
bob_point = sum([x for i, x in enumerate(cards) if i % 2 != 0])
print(alice_point - bob_point)


# Example run
# Input:
u+a
-9071
# Output:
-9071
N=int(input())
a=list(map(int,input().split()))
A=0
B=0
a.sort(reverse=True)
for i in range(N):
  if i%2==0:
    A+=a[i]
  else:
    B+=a[i]
print(A-B)

# Example run
# Input:
-10
453
# Output:
0
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)

print(sum(a[::2]) - sum(a[1::2]))

# Example run
# Input:
1
4887419
# Output:
4887419
n = int(input())
a = sorted([int(i) for i in input().split()], reverse=True)
print(sum(a[::2]) - sum(a[1::2]))


# Example run
# Input:
9062461
72046879
# Output:
72046879
N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
print(sum(A[::2]) - sum(A[1::2]))


# Example run
# Input:
-2147483648
450137
# Output:
450137
input()
a = sorted(map(int, input().split()))[::-1]
print(sum(a[::2])-sum(a[1::2]))

# Example run
# Input:
F!2eKDu
-84564737
# Output:
-84564737
n = int(input())
alice_cards = []
bob_cards = []
all_cards = list(map(int, input().split()))
all_cards.sort()
while len(all_cards) > 0:
    alice_cards.append(all_cards.pop(-1))
    if len(all_cards) == 0:
        break
    else:
        bob_cards.append(all_cards.pop(-1))
print(sum(alice_cards) - sum(bob_cards))

# Example run
# Input:
110
14005
# Output:
14005
n=int(input())
l=sorted(list(map(int,input().split())),reverse=True)
ANS=0
for i,v in enumerate(l):
  if i % 2 == 0:
    ANS += v
  else:
    ANS -= v
print(ANS)


# Example run
# Input:
-68
-31
# Output:
-31
input()
l=sorted(map(int,input().split()))[::-1]
print(sum(l[::2])-sum(l[1::2]))

# Example run
# Input:
xkU){S*1
-640183291
# Output:
-640183291
#6
N = int(input())
a = sorted(list(map(int, input().split())))
Alice_list = []
Bob_list = []
for i in range(1, N+1):
    if i%2==1:     
        Alice_list.append(a[-i])
    else:
        Bob_list.append(a[-i])
print(sum(Alice_list)-sum(Bob_list))

# Example run
# Input:
-7
-7737
# Output:
0
N = int(input())
alist = input().split()
alist = sorted(alist, reverse=True)
print(alist)
count = 1
alice = 0
bob = 0

for a in alist:
    if count % 2:
        alice += int(a)
    else:
        bob += int(a)
    count+=1
print(alice - bob)

# Example run
# Input:
4
-87
# Output:
['-87']
-87
n = int(input())
a = map(int, input().split())
b = list(a)
c = sorted(b, reverse=True)
print(sum(c[::2]) - sum(c[1::2]))

# Example run
# Input:
3420734
-989028
# Output:
-989028
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
a.reverse()
ans = 0
for i in range(len(a)):
    if i % 2 == 1:
        ans -= a[i]
    else:
        ans += a[i]

print(ans)

# Example run
# Input:
-1
-3439167
# Output:
-3439167
N = int(input())
A = list(map(int,input().split()))
a = 0
b = 0
A.sort(reverse=True)
for i in range(N):
    if i%2 == 0:
        a = a + A[i]
    if i%2 == 1:
        b = b + A[i+1]
print(a-b)

# Example run
# Input:
-7038374
-6
# Output:
0
N = int(input())
a = list(map(int,input().split()))

acnt =0
bcnt=0
a.sort(reverse=True)

for i in range(len(a)):
    if i%2==0:
        acnt += a[i]
    else:
        bcnt += a[i]
    
print(acnt-bcnt)

# Example run
# Input:
-473
-7
# Output:
-7
input()
card=sorted(map(int,input().split()))[::-1]
print(sum(card[::2])-sum(card[1::2]))

# Example run
# Input:
4EPy8r+|E
51856
# Output:
51856
N = int(input())
a = sorted(list(map(int, input().split())), reverse=True)

alice = sum(a[0::2])
bob = sum(a[1::2])

print(alice-bob)


# Example run
# Input:
367856
41
# Output:
41
N = int(input())
a = list(map(int, input().split()))
a.sort()
A = a[1::2]
B = a[0::2]
ScoreA = sum(A)
ScoreB = sum(B)
C = abs(ScoreA - ScoreB)
print(C)

# Example run
# Input:
253491
9005859
# Output:
9005859
N = int(input())
K = int(input())
X = list(map(int, input().split()))
res = 0
for x in X:
    res += 2 * min(x, K - x)
print(res)

# Example run
# Input:
-13902095
-168
5946
# Output:
-12228