Felix6326727/beyond-accuracy-code-comprehension huggingface dataset:
for_num = int(input())
nums = input()
nums = nums.split()
nums = sorted(nums,reverse=True)
print(nums)
A = 0
B = 0

for i in range(0,for_num):
  num = int(nums[i])
  if i%2 == 0:
    A += num
  else:
    B += num
print(A-B)

# Example run
# Input:
-554740
W'fMa)B=
# Output:
["W'fMa)B="]
0
N = int(input())
a_list = list(map(int,input().split()))
a_list.sort(reverse=True)
Alice = 0
Bob = 0

for i in range(0,len(a_list) + 1,2):
    if i < len(a_list):
        Alice = Alice + a_list[i]
    else:
        break

for j in range(1,len(a_list) + 1,2):
    if j < len(a_list):
        Bob = Bob + a_list[j]
    else:
        break

diff = Alice - Bob

print(diff)

# Example run
# Input:
57223618
-62350830
# Output:
-62350830
n=int(input())
a=list(map(int,input().split()))
a.sort()
b=a[0::2]#偶数番目
print(sum(a)-sum(b)*2)


# Example run
# Input:
-7038374
-6
# Output:
6
n = int(input())
cards = [i for i in map(int, input().split())]
alice = []
bob = []
for i in range(n):
    if i % 2 == 0:
        alice.append(max(cards))
        cards.pop(cards.index(max(cards)))
    else:
        bob.append(max(cards))
        cards.pop(cards.index(max(cards)))
print(sum(alice) - sum(bob))

# Example run
# Input:
-8201172
3646
# Output:
0
N=input()
a=list(set([int(j) for j in input().split()]))[::-1]
print(sum(a[::2])-sum(a[1::2]))

# Example run
# Input:
,.2]y,5m
1854844
# Output:
1854844
N = int(input())
A = [int(i) for i in input().split()]
A.sort(reverse=True)

if N == 1:
	print(A[0])
else:
	Alice = sum(A[0::2])
	Bob = sum(A[1::2])
	print(Alice-Bob)

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


solve()

# Example run
# Input:
44
51426
# Output:
51426
N = int(input())
points = sorted([int(i) for i in input().split()])[::-1]

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


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

# Example run
# Input:
-18853072
-46849
# Output:
-46849
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
a.append(0)
Ali,Bob=0,0
for i in range(0,n,2):
    Ali +=a[i]
    Bob +=a[i+1]
print(Ali-Bob)

# Example run
# Input:
-1
96
# Output:
0
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
al = []
bo = []
for idx, card in enumerate(a):
    if idx % 2 == 0:
        al.append(card)
    else:
        bo.append(card)
print(sum(al) - sum(bo))


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

a = sorted(a)
al = 0
bo = 0
for i, aa in enumerate(a):
    if i %2 == 0:
        al += aa
    else:
        bo += aa
print(al -bo)

# Example run
# Input:
28
30456987
# Output:
30456987
N = int(input())
num = [int(i) for i in input().split()]
num.sort(reverse=True)
a, b = 0, 0

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

print(a-b)

# Example run
# Input:
-5271130
19
# Output:
0
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+1)%2 == 1:
        alice += a
    else:
        bob += a

print(alice - bob)

# Example run
# Input:
-523929617
-147
# Output:
-147
n=int(input())
l=sorted((list(map(int, input().split()))),reverse=1)
print(abs(sum(l[::2])-sum(l[1::2])))

# Example run
# Input:
-227062494
655252
# Output:
655252
n=int(input())
l=sorted(list(map(int,input().split())),reverse=True)
l1=l[::2]
l2=l[1::2]
print(sum(l1)-sum(l2))


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

# Example run
# Input:
Xg<'3O.+[
1
# Output:
1
# -*- coding: utf-8 -*-
N = int(input())
aList = list(map(int, input().split()))
aList.sort(reverse=True)

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

print(Alice-Bob)

# Example run
# Input:
-4
66169
# Output:
66169
# -*- coding: utf-8 -*-

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

# solve
a.sort(reverse=True)

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


# Example run
# Input:
-58867430
-56661351
# Output:
-56661351
n=int(input())
a=list(map(int,input().split()))
a.sort()
ab=list(a[::2])
ac=list(a[1::2])
print(sum(ab)-sum(ac))
#print(ab)
#print(ac)

# Example run
# Input:
-40
-18579092
# Output:
-18579092
alice = 0
bob = 0
n = int(input())
a = list(map(int, input().split(' ')))
asrt = sorted(a, reverse = True)

for i in asrt[::2]: alice += i
for i in asrt[1::2]: bob += i
print(alice - bob)


# Example run
# Input:
-11392175
-9
# Output:
-9
#!/usr/bin/env python3

N = int(input())
A = sorted([int(a) for a in input().split()], reverse=True)

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

print(ans)


# Example run
# Input:
-87
141725276
# Output:
141725276
N = int(input())
a = list(map(int, input().split()))
a = sorted(a)[::-1]
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:
-89579
-64
# Output:
0
# atcoder では WAになる。なんで。
N = int(input())
a = list(map(int,input().split()))
a = sorted(a,reverse =True)
#
alice = []
bob = []
alice_total = 0
bob_total = 0
ans = 0
#
if N%2 == 0:
    for i in range(int(N/2)):
        alice.append(a[2*i])
        bob.append(a[2*i + 1])
elif N!=1:
    for j in range(int((N - 1)/2)):
        alice.append(a[2*j])
        alice.append(a[N - 1])
        bob.append(a[2*j + 1])
else:
    alice = a
#
alice_total = sum(alice)
bob_total = sum(bob)
ans = alice_total - bob_total
#
print(ans)


# Example run
# Input:
-1098720
-224231
# Output:
0
n = int(input())
cards = list(map(int, input().split()))
a = 0
b = 0

cards.sort(reverse=True)

for i in range(0, n):
    if (i % 2 == 0):
        a += cards[i]
    else:
        b += cards[i]

print(a - b)

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

A = []
B = []

while N > 0:
    A.append(max(a))
    a.remove(max(a))
    N -= 1
    if N != 0:
        B.append(max(a))
        a.remove(max(a))
        N -= 1

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

# Example run
# Input:
-9225256
339175880
# Output:
0
n = int(input())
A = list(map(int, input().split()))

Alice = 0
Bob = 0

A = list(sorted(A, reverse=True))

while True:
    if A != []:
        Alice += A.pop(0)
    else:
        break
    if A != []:
        Bob += A.pop(0)
    else:
        break

print(Alice-Bob)


# Example run
# Input:
-7467726
1372619017
# Output:
1372619017
n = int(input())
a = list(map(int, input().split()))
alice, bob = 0, 0
while len(a) > 0:
    alice += max(a)
    a.remove(max(a))
    if len(a) > 0:
        bob += max(a)
        a.remove(max(a))
    else:
        break
ans = alice - bob
print(ans)

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


# Example run
# Input:
3770
22710854
# Output:
22710854
# -*- coding: utf-8 -*-

# Nの入力
N = int(input())

# a1,a2 ~ aNまでの入力
a = list(map(int,input().split()))

# aの配列を降順にソートする
a.sort(reverse = True)

# aclie合計　と　bob合計
alice = sum(a[::2])
bob = sum(a[1::2])

# 出力
print(alice-bob)

# Example run
# Input:
20415230
-21
# Output:
-21
N = int(input())
a = list(map(int, input().split()))
A = []
B = []
while True:
  A.append(max(a))
  a.remove(max(a))
  if len(a) == 0:
    break
  B.append(max(a))
  a.remove(max(a))
  if len(a) == 0:
    break
print(sum(A)-sum(B))

# Example run
# Input:
1761864
0
# Output:
0
N = int(input())
A = [int(s) for s in 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:
-802253
-150069
# Output:
-150069
N = int(input())
a = list(map(int, input().split()))

a.sort(reverse=True)

result = sum(a[::2]) - sum(a[1::2])

print(result)

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

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


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

a.sort()

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

print(alice - bob)


# Example run
# Input:
5568815
11756850
# Output:
11756850
n=int(input())
a=[int(i) for i in input().split()] 
a.sort()
#print(a)
ans=0
flag=1
for i in range(n):
  ans+=flag*int(a[-1-i])
  flag=-1*flag
print(int(ans))


# Example run
# Input:
-90312
-12211339
# Output:
0
n=int(input())
li=list(map(int,input().split()))

x=0
y=0
for i in range(len(li)):
    for j in range(len(li)-1):
        if li[j]<li[j+1]:
            a=li[j]
            li[j]=li[j+1]
            li[j+1]=a


for k in range(len(li)):
    if k%2==0:
        x=x+li[k]
    else:
        y=y+li[k]

print(x-y)

# Example run
# Input:
0
-1859885
# Output:
-1859885
N = int(input())#数字
A = list(map(int, input().split()))  #リスト

A = sorted(A, reverse=True)

b = sum(A[::2])
c = sum(A[1::2])
print(b-c)

# Example run
# Input:
10026
70800
# Output:
70800
N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)
print(sum(A[::2]) - sum(A[1::2]))


# Example run
# Input:
387
5045691
# Output:
5045691
n = int(input())
arr = list(map(int,input().split()))

arr.sort()
arr.reverse()
A = sum(arr[0::2])
B = sum(arr[1::2])
print(A - B)

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


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

a.sort()
alice=[]
bob=[]
for i in range(n):
    x=a.pop(-1)
    if i%2==0:
        alice.append(x)
    else:
        bob.append(x)

print(sum(alice)-sum(bob))
        



# Example run
# Input:
-9071
21643
# Output:
0
N = int(input())
a = list(map(int, input().split()))
a.sort()
print(sum(a[0::2])-sum(a[1::2]))

# Example run
# Input:
755
3485
# Output:
3485
N=int(input())
A=list(map(int,input().split()))

A.sort(reverse=True)
ali=0
bob=0

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

# Example run
# Input:
2
15
# Output:
15
N = int(input())
A = sorted(map(int, input().split()))

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


# Example run
# Input:
-86
0
# Output:
0
n = int(input())
a_list = list(map(int, input().split()))

a_list.sort(reverse = True)
alice_sum = 0
bob_sum = 0
for i in range(len(a_list)):
    if i % 2 == 0:
        alice_sum += a_list[i]
    else:
        bob_sum += a_list[i]

print(alice_sum - bob_sum)

# Example run
# Input:
669
23
# Output:
23
N = int(input())
A = list(map(int, input().split()))

sorted_A = sorted(A, reverse=True)

alice = 0
bob = 0
for index, point in enumerate(sorted_A):

  # Alice
  if (index + 1) % 2 != 0:
    alice = alice + point
  
  # Bob
  else:
    bob = bob + point
 
answer = alice - bob

print(answer)

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


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

# Example run
# Input:
-15
3431161
# Output:
3431161
n = int(input())
a = list(map(int,input().split()))
a.sort()
a.reverse()
alice = 0
bob = 0
check = 1
for i in range(n):
	if check == 1:
		alice += a[i]
		check = check*(-1)
	else:
		bob += a[i]
		check = check*(-1)
print(alice-bob)

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

# Example run
# Input:
pi35
9545
# Output:
9545
N=int(input())
A=list(map(int,input().split()))

A=sorted(A)[::-1]
a=0
b=0

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

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

# Example run
# Input:
-29
-5363
# Output:
0
n = int(input())
array = list(map(int, input().split()))

bob = []
alice = []
for i in range(1, n+1):
    if i % 2 == 1:
        max_value = max(array)
        array.remove(max_value)
        alice.append(max_value)
    else:
        min_value = min(array)
        array.remove(min_value)
        bob.append(min_value)

print(sum(alice)-sum(bob))


# Example run
# Input:
-4
-1008
# Output:
0
N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)

ans = sum(a for a in A[::2]) - sum(a for a in A[1::2])

print(ans)

# Example run
# Input:
0
-6956
# Output:
-6956
N = int (input ())
L = input ().split ()
l = [int(s) for s in L]
list.sort (l, reverse=True)
a = 0
x = 0
y = 0
while True:
    x += int (l[a])
    a += 1
    if a == N:
        break
    y += int (l[a])
    a += 1
    if a == N:
        break
print (x-y)

# Example run
# Input:
1
8030667
# Output:
8030667
sumajedan = 0
sumadva = 0

n = int(input())

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

a.sort(reverse = True)

for x in range(n):
    if x%2 == 0:
        sumajedan=sumajedan + a[x]
    else:
        sumadva = sumadva + a[x]
print(sumajedan - sumadva)

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

A.sort(reverse=True)

Alice_point = sum(A[::2])
Bob_point = sum(A[1::2])

print(Alice_point - Bob_point)

# Example run
# Input:
-253690
-1
# Output:
-1
n = int(input())
a = list(map(int, input().split()))
alice, bob = 0, 0
for i in range(n):
    temp_max = max(a)
    a.remove(temp_max)
    if i % 2 == 0:
        alice += temp_max
    else:
        bob += temp_max
print(alice - bob)

# Example run
# Input:
-4752443
693
# Output:
0
n = input()
l = sorted(list(map(int, input().split())), reverse=True)

alice = 0
bob = 0
for key, value in enumerate(l):
    if key % 2 == 0:
        alice += value
    else:
        bob += value
print(alice - bob)


# Example run
# Input:
9_7kUR
-87
# Output:
-87
n=int(input())
x=list(map(int,input().split()))
x.sort(reverse=True)
ans=0
for i in range(n):
  ans+=x[i]*(-1)**i
print(ans)

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

# Example run
# Input:
pg(K
-585248031
# Output:
-585248031
N = int(input())
a = map(int,input().split())

A = sorted(a, reverse=True)

Alice = 0
Bob = 0


for i in A[0::2]:
  Alice += i
  
for _ in A[1::2]:
  Bob += _
  
ans = Alice -Bob
  
print(ans)



# Example run
# Input:
6552
7
# Output:
7
def main():
    n = int(input())
    a = list(map(int, input().split()))
    score = [0, 0]
    sort_a = sorted(a, reverse=True)
    print(sort_a)

    for i in range(n):
        if i >= 2:
            sub_i = i % 2
        else:
            sub_i = i
        score[sub_i] += sort_a[i]

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


if __name__ == "__main__":
    main()

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

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

# Example run
# Input:
}[^h=c=?
1
# Output:
1
N=int(input())
a=list(map(int, input().split()))
a.sort()
s1=0
s2=0
#print(a)
for i in range(N) :
    if i%2 == 0 :
        s1+=a[i]
    else :
        s2+=a[i]
print(abs(s1-s2))

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

a = 0
b = 0

for i in list:
  if i % 2 == 0:
    a += list[i]
  else:
    b += list[i]

print(a - b)

# Example run
# Input:
5182
0
# Output:
0
#!/usr/bin/env python
# coding: utf-8

# In[10]:


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


# In[11]:


a_s = sorted(a, reverse=True)
alice = sum(a_s[::2])
bob = sum(a_s[1::2])
print(alice-bob)


# In[ ]:






# Example run
# Input:
-1136688451
992
# Output:
992
n=int(input())
s=list(map(int,input().split()))
s=sorted(s,reverse=True)
k=0
for i in range(n):
  if i%2==0:
    k+=s[i]
  else:
    k-=s[i]
print(k)

# Example run
# Input:
-1351531223
-7517
# Output:
0
n = int(input())
a = list(map(int,input().split()))
a.sort()
c = 0
d = 0
for i in range(n):
    if i % 2 == 0:
        c += a[i]
    else:
        d += a[i]
print(c-d)

# Example run
# Input:
0
-1251521
# Output:
0
n = int(input())
a = sorted([int(i) for i in input().split()],reverse=True)
A = [a[0]]
B = []
for i in range(1,n):
  if i % 2 == 0:
    A.append(a[i])
  else:
    B.append(a[i])
print(sum(A)-sum(B))

# Example run
# Input:
-25867257
-2147483648
# Output:
-2147483648
N = int(input())
B = list(map(int, input().split()))

one =[]
two =[]
count = 0
if N%2 ==0:
  while count <= N-1:
    one.append(max(B))
    B.remove(max(B))
    two.append(max(B))
    B.remove(max(B))
    count +=2
else:
  while count <= N-2:
    one.append(max(B))
    B.remove(max(B))
    two.append(max(B))
    B.remove(max(B))
    count +=2
  one.append(max(B))
  B.remove(max(B))

print(sum(one)-sum(two))

# Example run
# Input:
1
4887419
# Output:
4887419
n = int(input())
cards = list(map(int, input().split()))
result = 0
result2 = 0

while(cards != []):
    result += max(cards)
    cards.remove(max(cards))
    if cards != []:
        result2 += max(cards)
        cards.remove(max(cards))

print(result-result2)


# Example run
# Input:
-3550
-11385106
# Output:
-11385106
# coding:utf-8
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort(reverse=True)
    alice_score = 0
    bob_score = 0

    for loop,num in enumerate(a):
        if loop % 2 == 0:
            alice_score += num
        else: bob_score += num 

    print(alice_score - bob_score)

if __name__ == '__main__' :
    main()

# Example run
# Input:
-109089799
-74270783
# Output:
-74270783
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
ans=0
for i in range(0,n,2):
  ans+=a[i]
for i in range(1,n,2):
  ans-=a[i]
print(ans)

# Example run
# Input:
-1
-3439167
# Output:
0
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    n = int(input())
    a = input().split()

    bob = 0
    alice = 0
    sort_a = sorted(a, reverse=True)
    count = 0
    for m in range(len(sort_a)):
        if m % 2 == 0:
            alice = alice + int(sort_a[m])
        else:
            bob = bob + int(sort_a[m])

    print(alice - bob)


# Example run
# Input:
-1
-3439167
# Output:
-3439167
N = int(input())
a = [int(i) for i in input().split()]

b = []
for i in range(N):
    b.append(max(a))
    a.remove(max(a))

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

result = Alice - Bob
print(result)

# Example run
# Input:
-15015728
42339391
# Output:
0
N = 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:
fX_C`P
129445
# Output:
129445
#カードの総数
N = int(input())
#それぞれのカードのリスト
a = list(map(int, input().split()))
a.sort
#aliceのリスト
alice_list = []
#bobのリスト
bob_list = []

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

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

alice_num = sum(alice_list)
bob_num = sum(bob_list)
ans = alice_num - bob_num
print(ans)





# Example run
# Input:
-800148
-42415
# Output:
0
N = int(input())
an = list(map(int, input().split()))

alis,bob = 0, 0
for i in range(N):
  if i%2 == 0:
    alis += max(an)
    an[an.index(max(an))]= 0
  elif i%2 == 1:
    bob += max(an)
    an[an.index(max(an))] = 0

print(alis - bob)

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

# Example run
# Input:
-109089799
-74270783
# Output:
-74270783
n = int(input()) 
t = [int(i) for i in input().split()] 

t = sorted(t,key = lambda x:-x)

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

# Example run
# Input:
308986
92
# Output:
92
n = int(input())
nums = list(map(int,input().split()))
alice = 0
bob = 0

nums.sort()
while nums:
    alice+=nums.pop()
    if nums:
        bob+=nums.pop()

print(alice-bob)

# Example run
# Input:
-1008
145668163
# Output:
145668163
n = int(input())
li = list(map(int, input().rstrip().split()))

li.sort()
li_rev = li[::-1]

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

# Example run
# Input:
-38
-17
# Output:
-17
n=int(input())
lista=list(map(int,input().split()))
lista.sort(reverse=True)
alice=list()
bob=list()
for i in range(n):
    if i%2==0:
        alice.append(lista[i])
        
    else: 
        bob.append(lista[i])

print(sum(alice)-sum(bob))

# Example run
# Input:
-2090237817
-14
# Output:
0
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
alice = sum(a[::2])
bob = sum(a[1::2])
ans = alice - bob
print(ans)


# Example run
# Input:
-122
-2551940
# Output:
-2551940
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
flag = 0
alice = 0
bob = 0
for i in a:
    if flag == 0:
        alice += i
        flag = 1
    else:
        bob += i
        flag = 0
print(alice-bob)


# Example run
# Input:
11
5831819
# Output:
5831819
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse = True)
p = 0
for i in range(N):
    p += (-1)**(i) * A[i]
print(p)


# Example run
# Input:
-1836
-168854
# Output:
0
N = int(input())
list_all = list(map(int, input().split()))

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




# Example run
# Input:
363865392
-1377730
# Output:
-1377730
n=int(input())
lst=list(map(int,input().split()))
lst.sort(reverse=True)
Alice=0
Bob=0
for i in range(n):
  if i%2==0:
    Alice+=lst[0]
    del lst[0]
  else:
    Bob+=lst[0]
    del lst[0]
print(Alice-Bob)

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

alice = 0
bob = 0

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

print (alice - bob)



# Example run
# Input:
39756387
-7467726
# Output:
-7467726
while True:
    try:
        str = input()
        ans = ''
        # flag
        n = 1
        
        for c in str:
            if '@' == c:
                n = 0
            elif n < 1:
                n = int(c)
            else:
                ans += c * n
                n = 1
        print(ans)
    except:
        break
        


# Example run
# Input:
D,]
# Output:
D,]
while True:
    try:
        S = input()
    except EOFError:
        break
    ans = ''
    i = 0
    while i < len(S):
        if S [i] == '@':
            ans += S [i + 2] * int(S [i + 1])
            i += 3
        else:
            ans += S [i]
            i += 1
    print(ans)

# Example run
# Input:
Sz50Gg>x
# Output:
Sz50Gg>x
while True:
	try:
		line=list(map(str,input()))
		string=""
		for i in range(len(line)):
			if (line[i]!='@' and line[i-1]!='@' and line[i-2]!='@'):
				string+=line[i]
			elif line[i]=='@':
				string+=line[i+2]*int(line[i+1])
			else:
				pass
		print(string)
	except EOFError:
		break
		
				

# Example run
# Input:
e3zvshd]
# Output:
e3zvshd]