Felix6326727/beyond-accuracy-code-comprehension huggingface dataset:
n=int(input())
a=list(map(int,input().split()))
a.sort()
x=y=0
while True:
  if len(a)>0:
    x+=a.pop()
  else:
    break
  if len(a)>0:
    y+=a.pop()
  else:
    break
print(x-y)

# Example run
# Input:
3556893
-8951
# Output:
-8951
n=int(input())
alis=sorted(list(map(int,input().split())))[::-1]
acount=0
bcount=0
for i in range(n):
	if i%2 ==0:
		acount+=alis[i]
	else:
		bcount+=alis[i]
print(acount-bcount)

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

alice = 0
bob = 0

a.sort(reverse=True)

cnt = 0

for i in a:
    if (cnt%2==0):
        alice += i
    else:
        bob += i
    cnt += 1

print(alice - bob)

# Example run
# Input:
-630
-11385935
# Output:
-11385935
N=int(input())
A=list(map(int,input().split()))
s=0
A.sort()

for i in range(N//2):
  s+=A[2*i]-A[2*i+1]
if N%2==1:
  s+=A[N-1]
print(s)

# Example run
# Input:
-2552
-330190783
# Output:
0
# coding: utf-8

N = int(input())
a = [int(x) for x in input().split()]
a.sort(reverse = True)

alice_point = 0
bob_point = 0
for index in range(N):
	if index % 2 == 0:
		alice_point += a[index]
	else:
		bob_point += a[index]

print(alice_point - bob_point)

# Example run
# Input:
-60
-2147483648
# Output:
0
n=int(input())
a_list=list(input().split())
a_list.sort(reverse=True)
a = 0
b = 0
for i in range(len(a_list)):
    if i % 2 == 0:
        a += int(a_list[i])
    else:
        b += int(a_list[i])
print(a-b)

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

print(abs(sum(A[0:n:2]) - sum(A[1:n:2])))

# Example run
# Input:
252153
173921
# Output:
173921
n = int(input())
cards = map(int, input().split(' '))
sorted_cards = sorted(cards,reverse=True)

alice_sum = 0
bob_sum = 0
for i in range(n):
    if i % 2 == 0:
        alice_sum += sorted_cards[i]
    else:
        bob_sum += sorted_cards[i]

print(alice_sum - bob_sum)

# Example run
# Input:
-9
89
# Output:
0
n = int(input())
a = [int(i) for i in input().split()]
alice = 0
bob = 0
a = sorted(a)
for i in range(n):
    if i%2==0:
        alice += a[i]
    else:
        bob += a[i]
print(abs(bob-alice))

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

a.sort(reverse = True)
L = [0, 0]
f = 0
for i in a:
  L[f] += i
  f = 1 - f

print(L[0] - L[1])

# Example run
# Input:
-4
2072477
# Output:
2072477
n = int(input())
a = list(map(int, input().split()))
a.sort()
alice = 0
bob = 0
for i in range(n):
  if i % 2 == 0:
    alice += a[-(i+1)]
  else:
    bob += a[-(i+1)]
    
print(alice - bob)




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


# Example run
# Input:
-5271130
19
# Output:
19
N = list(map(int,input().split()))
Ai = list(map(int,input().split()))
if N[0]%2 != 0:
    Ai.append(0)
Ai.sort(reverse = True)
Alice = 0
Bob = 0
for i in range(len(Ai)//2):
    Alice += Ai[2*i +1]
    Bob += Ai[2*i]
print(Bob - Alice)


# Example run
# Input:
-2
184
# Output:
0
N = int(input())
numbers = list(map(int, input().split()))
Alice_point = 0
Bob_point = 0

numbers.sort()
print(numbers)

while True:
    try:
        Alice_point += numbers[0]
        Bob_point += numbers[1]
        numbers.remove(numbers[0])
        numbers.remove(numbers[0])
    except IndexError:
        break

print(Alice_point - Bob_point)

# Example run
# Input:
166977
-4752443
# Output:
[-4752443]
-4752443
n=int(input())
la=sorted(list(map(int, input().split())),reverse=True)
a=b=0
for i in range(0,n,2):
    a+=la[i]
for i in range(1,n,2):
    b+=la[i]
print(abs(b-a))

# Example run
# Input:
-227170451
13499019
# Output:
0
n=int(input())
l=(list(map(int,input().split()))) 
l.sort(reverse=True)
for i in range(n):
    if i%2==1:
        l[i]=-l[i]
print(sum(l))

# Example run
# Input:
-336241
14
# Output:
14
n = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
Alice = 0
Bob = 0
for i in range(0, len(a), 2):
    Alice += a[i]
    if i + 1 < len(a):
        Bob += a[i + 1]
print(Alice - Bob)


# Example run
# Input:
22710854
-2147483648
# Output:
-2147483648
##Just for prctice
n=int(input())

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

A.sort()
A.reverse()
a=0
b=0
for i in range(n):
    if i%2==0:
        a+=A[i]
    else:
        b+=A[i]

print(a-b)

"""
2
3 1

2

3
2 7 4

5

4
20 18 2 18

18
"""




# Example run
# Input:
-507621088
28016
# Output:
0
n=int(input())
a=sorted(map(int,input().split()),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:
1
-124978655
# Output:
-124978655
#金額
moto = int(input())
num   = int((moto + 1 ) / 2)
retu    = input().split()
card = list( map((lambda x:int(x)),retu))
cardList = sorted(card, reverse=True)
Alice = 0
Bob = 0

for w in range(num):
    Alice = Alice + cardList[w*2]
    if moto > (w*2+1):
        Bob = Bob + cardList[w*2+1]

print(Alice - Bob)


# Example run
# Input:
-5
-14993
# Output:
0
N = int(input())
a = list(map(int,input().split()))
a.sort()
a.reverse()
Alice = []
Bob = []
if N % 2 == 0:
    for i in range(N//2):
        Alice.append(a[i*2])
        Bob.append(a[i*2+1])
    print(sum(Alice) - sum(Bob))
elif N % 2 == 1 and N != 1:
    for i in range((N-1)//2):
        Alice.append(a[i*2])
        Bob.append(a[i*2+1])
    Alice.append(a[-1])
    print(sum(Alice) - sum(Bob))
elif N == 1:
    print(a[0])

# Example run
# Input:
-2147483648
-2500715
# Output:
0
n = int(input())
a = list(sorted(list(map(int,input().split())),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:
0
805965556
# Output:
0
n=int(input())
a=list(map(int,input().split()))
a.sort()
x=0
y=0
for i in range(0,n,2):
    x+=a[i]
for i in range(1,n,2):
    y+=a[i]

print(abs(x-y))


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

# Example run
# Input:
<F=EjU8Y
-562
# Output:
-562
N = int(input())
A = sorted(list(map(int, input().split())),reverse = True)

Gap = sum(A)

if N!=1:
    for i in range(N//2):
       Gap += -2*A[1+2*i]

print(Gap)

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


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

# Example run
# Input:
1036536343
-5875
# Output:
-5875
n=int(input())
a=[int(i) for i in input().split()]
a.sort(reverse=True)
Alice=[0,0]
Bob=[0,0]
for i in a:
  if Alice[1]==Bob[1]:
    Alice[0]+=i
    Alice[1]+=1
  else:
    Bob[0]+=i
    Bob[1]+=1
print(Alice[0]-Bob[0])

# Example run
# Input:
11
-40
# Output:
-40
n = int(input())
a = [int(x) for x in input().split()]
a.sort(reverse=True)
s = sum(a)
sa = sum(a[::2])
print(2*sa-s)


# Example run
# Input:
-1051
-27
# Output:
-27
# -*- coding: utf-8 -*-

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

cards = sorted(a)
alice = cards[-1::-2]
bob = cards[-2::-2]

ans = sum(alice) - sum(bob)

print(ans)


# Example run
# Input:
21507
197383
# Output:
197383
i = int(input())
a = list(map(int, input().split()))
a.sort()
a.reverse()
alice = a[0::2]
bob = a[1::2]
print(sum(alice) - sum(bob))


# Example run
# Input:
14755112
63
# Output:
63
N=int( input())
a=list(set([int(j) for j in range(N)]))
print(sum(a[::2])-sum(a[1::2]))

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

a.sort(reverse=True)

Alice = sum(a[::2])
Bob = sum(a[1::2])

print(Alice-Bob)

# Example run
# Input:
43064
-3108573
# Output:
-3108573
n = int(input())
lst = [int(i) for i in input().split()]
lst.sort()
lst = lst[::-1]
sum_a = 0
sum_b = 0
for i in range(n):
    if i%2==0:
        sum_a += lst[i]
    else:
        sum_b += lst[i]
print(sum_a - sum_b)

# Example run
# Input:
-31766
-1
# Output:
0
N = int(input())
a_list = list(map(int, input().split()))

a_sorted_list = sorted(a_list, reverse=True)

score_Alice = 0
score_Bob = 0

for i in range(N):
  if i % 2 == 0:
    score_Alice += a_sorted_list[i]
  else:
    score_Bob += a_sorted_list[i]

print(score_Alice - score_Bob)

# Example run
# Input:
-168854
-5
# Output:
0
n = int(input())
array = list(map(int,input().split()))
a = b = 0
for i, m in enumerate(sorted(array, reverse=True)):
    if i == 0 or i % 2 == 0:
        a += m
    if i % 2 != 0:
        b += m
print(a-b)

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


# Example run
# Input:
1
-38175
# Output:
-38175
input()
a = list(reversed(sorted([int(i) for i in input().split()])))
print(sum(a[::2]) - sum(a[1::2]))

# Example run
# Input:
tcM
-1530217
# Output:
-1530217
N = int(input())
A = list(map(int, input().split()))

alice = 0
bob = 0

A_rev = sorted(A, reverse=True)

while True:
    if len(A_rev) != 0:
        alice += A_rev.pop(0)
    
    if len(A_rev) != 0:
        bob += A_rev.pop(0)
    
    if len(A_rev) == 0:
       break
 
print(alice - bob)

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

# Example run
# Input:
-464240
19804
# Output:
19804
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
sum1 = 0
sum2 = 0
for j in range(N):
    if j%2 == 0:
        print(a[j])
        sum1 = sum1 + a[j]
    elif j%2 ==1:
        print(a[j])
        sum2 = sum2 + a[j]
print(sum1 - sum2)


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

sort_a = a[::-1]
Alice = sum(sort_a[0:N:2])
Bob = sum(sort_a[1:N:2])

print(Alice - Bob)


# Example run
# Input:
33729406
142
# Output:
142
def resolve():
  N = int(input())
  A = [int(i) for i in input().split()]
  
  A = sorted(A, reverse=True)
  alice = 0
  bob = 0
  for i in range(0, len(A), 2):
    alice += A[i]
    if i+1 < len(A):
      bob += A[i+1]

  print(alice - bob)
  
resolve()

# Example run
# Input:
3537
-4816
# Output:
-4816
number = input().rstrip()

card = input().rstrip().split()

card2 = sorted(card, reverse = True)

alice = 0
bob = 0


for i in range(0, len(card2), 2):
    alice += int(card2[i])

for i in range(1, len(card2), 2):
    bob += int(card2[i])

print(alice - bob)

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

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

A=B=I=0
for i in a:
    if I %2:B+=i
    else:A+=i
    I+=1

print(A-B)
# other
# print(sum(a[::2]) - sum(a[1::2]))


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




# Example run
# Input:
-224960337
446
# Output:
0
N = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
print(sum(a[0::2])-sum(a[1::2]))


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

A=0
B=0
a=sorted(a,reverse=True)

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

print(A-B)


# Example run
# Input:
-316
-160045822
# Output:
0
N = int(input())
A = list(map(int, input().split()))

A = sorted(A, reverse=True)
print(sum(A[::2]) - sum(A[1::2]))


# Example run
# Input:
-1
-3439167
# Output:
-3439167
if __name__ == '__main__':
    N = int(input())
    A_list = list(map(int, input().split()))

    A_list = sorted(A_list, reverse=True)

    odd_A_list = A_list[::2]
    even_A_list = A_list[1::2]

    print(sum(odd_A_list)-sum(even_A_list))

# Example run
# Input:
-658328
633
# Output:
633
N=int(input())
A=list(map(int,input().split()))

A.sort()

x=sum(A[-1::-2])
y=sum(A[-2::-2])
print(x-y)

# Example run
# Input:
897
-1003686
# Output:
-1003686
#coding:utf-8
N = input()
L = list(map(int,input().split()))
L.sort()
L.reverse()

cnt = 0

for i in range(len(L)):
    if i % 2 == 0:
        cnt += L[i]
    else:
        cnt -= L[i]

print(cnt)


# Example run
# Input:
`B)goR
2851
# Output:
2851
import math 
N = int(input())
L = list(map(int, input().split()))

L = sorted(L, reverse=True)

Alice = 0
Bob = 0
count = 0

for i in range (0, len(L)):
	if count == 0:
		Alice+=L[i]
		count=1
	else:
		Bob+=L[i]
		count=0

print(Alice-Bob)

# Example run
# Input:
1045415
-68
# Output:
-68
N = int(input())
a = list(map(int ,input().split()))
A = 0
B = 0
for i in range(N) :
    A += max(list(a))
    a.remove(max(list(a)))
    a.append(0)
    B += max(list(a))
    a.remove(max(list(a)))
    a.append(0)



print(A - B)

# Example run
# Input:
-1921542
0
# Output:
0
n = int(input())
ls = list(map(int, input().split()))
ls.sort(reverse=True)
alice_point = 0
bob_point = 0

for i in range(n):
  if i % 2 == 0:
    alice_point += ls[i]
  else:
    bob_point += ls[i]

difference = alice_point - bob_point
print(difference)

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

Alice = 0
Bob = 0

for i in range(len(a_list)):
    if i % 2 == 0:
        Alice += a_list[i]
    else:
        Bob += a_list[i]

print(Alice-Bob)


# Example run
# Input:
-8201172
3646
# Output:
3646
n = int(input())
a_list = list(map(int, input().split()))
a_list.sort(reverse=True)
alice = 0
bob = 0
for i,a in enumerate(a_list):
  if i % 2 == 0:
    alice += a
  else:
    bob += a
print(abs(alice-bob))

# Example run
# Input:
-112
-246934
# Output:
246934
a = list(map(int, input().split()))
b=sorted(a, reverse=True)
print(sum(b[0::2])-sum(b[1::2]))

# Example run
# Input:
-812896393
# Output:
-812896393
n = int(input())
a = [int(i) for i in input().split()]
sum1 = 0
sum2 = 0
sum3 = 0
sum4 = 0
if n % 2 == 0:
	for s in range(n):
		if s % 2 == 0:
			sum1 += a[s]
		else:
			sum2 += a[s]
	print(max(sum1, sum2) - min(sum1, sum2))
else:
	for s in range(n):
		if s % 2 == 0:
			sum1 += a[s]
		else:
			sum2 += a[s]
	sum3 = sum1 - a[0]
	sum4 = sum2 + a[0]
	ans1 = max(sum1, sum2) - min(sum1, sum2)
	ans2 = max(sum3, sum4) - min(sum3, sum4)
	print(max(ans1, ans2))

# Example run
# Input:
-2058894
298151
# Output:
0
def main():
  ans = 0
  n = int(input())
  l = list(map(int, input().split()))
  l.sort(reverse=True)
  for i in range(len(l)):
    if i % 2 == 0:
      ans += l[i]
    else:
      ans -= l[i]
  print(ans)

if __name__ == '__main__':
  main()

# Example run
# Input:
0
-54266464
# Output:
-54266464
N = int(input().strip())
l = list(map(int, input().strip().split()))

sl = sorted(l, reverse = True)

A = []
B = []

for _ in range(len(l)):
  if _%2 == 0:
    A.append(sl[_])
  else:
    B.append(sl[_])

gap = sum(A) - sum(B)

print(gap)

# Example run
# Input:
6534
2147483647
# Output:
2147483647
n=int(input())
a=list(map(int,input().split()))
aa=sorted(a,key=int,reverse=True)
Ali=0
Bob=0
for i in range(n):
	if i%2==0:
	    Ali+=aa[i]
	else:
	    Bob+=aa[i]
print(Ali-Bob)

# Example run
# Input:
-3550
-11385106
# Output:
0
n = int(input())
c = list(map(int, input().split()))
c.sort(reverse=True)
a = sum(c[::2])
b = sum(c[1::2])
print(a - b)

# Example run
# Input:
108280
-2848852
# Output:
-2848852
n = int(input())
l = sorted(map(int, input().split()))
a = 0
b = 0
for i in range(n):
  if i % 2 == 0:
  	a += l.pop()
  else:
    b += l.pop()
print(a - b)

# Example run
# Input:
-87
141725276
# Output:
0
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:
-23909
-68
# Output:
0
N = int(input()) # 入力数
L1 = input().split(" ")
# print(L1)
L2 = list(map(int, L1))
A = []
B = []


# print("modeB")
for n in range(N - 1):
    A.append(max(L2))
    L2.remove(max(L2))
    # print(A)
    if L2 == []:
        break
    B.append(max(L2))
    # print(B)
    L2.remove(max(L2))
    if L2 == []:
        break
    n += 1

# print(A, "f")
# print(B, "f")
PA = sum(A)
PB = sum(B)
print(PA - PB)



# Example run
# Input:
449660
0
# Output:
0
n = int(input())
nums = sorted(map(int, input().split()), reverse=True)
a = sum(nums[::2])
b = sum(nums[1::2])
print(a - b)


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

# Example run
# Input:
-89579
-64
# Output:
64
input()
a = list(map(int, input().split()))

a.sort(reverse=True)

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

print(alice-bob)


# Example run
# Input:
<W_K
-56834839
# Output:
-56834839
n = int(input())
xs = list(sorted(list(map(int, input().split()))))[::-1]

ans = 0
s = 1
for x in xs:
  ans += s * x
  s *= -1
print(ans)

# Example run
# Input:
30315
-65
# Output:
-65
N = int(input())
a = list(map(int, input().split()))
r = sorted(a, reverse=True)
ans = 0
for i in range(N):
  if i % 2 == 0:
    ans += r[i]
  else:
    ans -= r[i]
print(ans)

# Example run
# Input:
-14
0
# Output:
0
n = int(input())
a = list(map(int, input().split()))
m,p = 0,0
a.sort()
if len(a)%2==0:
    for i in range(0,len(a),2):
        m+=a[i]
    for i in range(1,len(a),2):
        p+=a[i]
else:
    for i in range(0,len(a),2):
        p+=a[i]
    for i in range(1,len(a),2):
        m+=a[i]
print(p-m)

# Example run
# Input:
5354599
52
# Output:
52
dat =list(input().split())

for i in dat:
	i = int(i)

dat.sort()
dat.reverse()

asum = 0
bsum = 0
sum=0

for i in range(len(dat)):
     sum =  dat[i]
		
print(sum)

# Example run
# Input:
-3108573
# Output:
-3108573
N = int(input())
a_s = list(map(int, input().split()))

a_s.sort(reverse=True)
Alice = a_s[0::2]
Bob = a_s[1::2]
print(sum(Alice) - sum(Bob))


# Example run
# Input:
0
695
# Output:
695
N = int(input())
A = [int(x) for x in input().split()]

def main():
    A.sort(reverse=True)
    alist = [x for i, x in enumerate(A) if i % 2 == 0]
    blist = [x for i, x in enumerate(A) if i % 2 != 0]
    print(sum(alist) - sum(blist))

if __name__ == "__main__":
    main()

# Example run
# Input:
112430
-17895
# Output:
-17895
number=input()
number=int(number)
card=input().rstrip().split()
card=list(map(int,card))
alice=0
bob=0
for i in range(number):
    a=max(card)
    if i%2==0:
        alice+=a
    else:
        bob+=a
    del card[card.index(max(card))]
print(alice-bob)


# Example run
# Input:
-168854
-5
# 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:
-2243514
5183902
# Output:
5183902
n = int(input())
a = list(map(int, input().split()))

a.sort(reverse=True)
if n%2 == 1:
    a.append(0)
    n += 1
ans = 0
for i in range(n//2):
    ans += a[2*i]
    ans -= a[2*i+1]
print(ans)

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

A.sort()
A.reverse()

Alice = sum(A[0::2])
Bob = sum(A[1::2])

print(Alice - Bob)

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

# Example run
# Input:
-24
-35784
# Output:
-35784
num = input().split(" ")

num.sort(reverse=True)

A = 0
B = 0
t=0
for i in num:
    if t%2==0:
        A+=int(i)
        print(i)
        print(t)
    else:
        B+=int(i)
    t+=1
print(A-B)

# Example run
# Input:
45236
# Output:
45236
0
45236
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:
212
-11989124
# Output:
-11989124
n = int(input())
a= list(input().split())
a = [int(i) for i in a]

a.sort()
a.reverse()

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:
-8808386
-5721
# Output:
0
n=int(input())
a=list(map(int,input().split()))
a.sort()

alice=0
bob=0

for i in range(n):
  if i%2==0:
    alice+=a[n-i-1]
  else:
    bob+=a[n-i-1]
print(alice-bob)



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

# Example run
# Input:
134
-5930
# Output:
-5930
n=int(input())
ans=0
A=sorted(list(map(int,input().split())))[::-1]
for i in range(n):
  if i % 2 == 0:
    ans += A[i]
  else:
    ans -= A[i]
print(ans)

# Example run
# Input:
-23
8029
# Output:
0
import sys
import math
n = int(input())
li = list(map(int, input().split()))
li.sort(reverse=True)
alice = 0
bob = 0
for i in range(0, len(li) - 1, 2):
    alice += li[i]
    bob += li[i + 1]
if (len(li) % 2 != 0):
    alice+=li[-1]
print(alice-bob)

# Example run
# Input:
-2102
3
# Output:
3
input()
a = list(map(int, input().split()))
a.sort(reverse=True)
print(sum(a[::2]) - sum(a[1::2]))


# Example run
# Input:
C;.a]hEfu
-47
# Output:
-47
n = int(input())
a = sorted(list(map(int, input().split())))
Alice = 0
Bob = 0
for i in range((n+1)//2):
    Alice += a.pop()
    if a != []:
        Bob += a.pop()
print(Alice - Bob)

# Example run
# Input:
-2773
3897539
# Output:
0
N = int(input())
A = [int(a) for a in input().split()]
A.sort()
A.reverse()
s = 0
for n in range(N):
    if n % 2 ==0:
        s += A.pop(0)
    else:
        s -= A.pop(0)
print(s)

# Example run
# Input:
-2
669
# 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:
-2239572
-31
# Output:
-31
n = int(input())
a = list(map(int, input().split()))

alice = 0
bob = 0

a.sort()
a.reverse()

for i in a[::2]:
    alice += i

for j in a[1::2]:
    bob += j

print(alice-bob)

# Example run
# Input:
-554740
65444
# Output:
65444
def readinput():
    n=int(input())
    a=list(map(int,input().split()))
    return (n,a)

def main(n,a):
    a.sort(reverse=True)
    nloop=n//2
    apoint=0
    bpoint=0
    l=0
    while(l<nloop):
        apoint+=a[l*2]
        bpoint+=a[l*2+1]
        l+=1
    if(n%2==1):
        apoint+=a[n-1]
    return apoint-bpoint


if __name__=='__main__':
    n,a = readinput()
    ans=main(n,a)
    print(ans)


# Example run
# Input:
-2147483648
-33
# Output:
0
def B_Card_Game_for_Two():
    N=int(input())
    a=list(map(int, input().split()))
    a.sort(reverse=True)
    A=a[::2]
    B=a[1::2]
    print(sum(A)-sum(B))

B_Card_Game_for_Two() 

# Example run
# Input:
0
11
# Output:
11
n = int(input())
a = sorted(map(int, input().split()))[::-1]

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

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

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

# Example run
# Input:
-3724
-24296024
# Output:
0
N = int(input())
a_list = [int(num) for num in input().split()]
a_list.sort(reverse=True)

alice = 0
bob = 0

for i, num in enumerate(a_list, 1):
  if i % 2:
    alice = alice + num
  else:
    bob = bob + num
print(alice-bob)

# Example run
# Input:
-160045822
155287
# Output:
155287
N = int(input())
a_list = list(map(int, input().split()))

sum = 0
i = 0
while len(a_list) > 0:
    number = a_list.pop(a_list.index(max(a_list)))
    if i % 2 == 0:
        sum += number
    else:
        sum -= number
    i += 1
print(sum)

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



# Example run
# Input:
-1
732970
# Output:
732970