Felix6326727/beyond-accuracy-code-comprehension huggingface dataset:
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(alice-bob)

# Example run
# Input:
-7038374
-6
# Output:
0
# coding: utf-8
n = int(input())
cards = sorted(list(map(int, input().split())))

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

# Example run
# Input:
-3122
424
# Output:
0
N=int(input())
L=list(map(int,input().split()))
L.sort(reverse=True)
Bob, Alice=0,0
for i in range(0,N,2):
  Alice=Alice+L[i]
for i in range(1,N,2):
  Bob=Bob+L[i]
print(Alice-Bob)

# Example run
# Input:
-37
1
# Output:
0
n  = int(input())
aa = [int(i) for i in input().split()]

aa = sorted(aa)

a, b, is_a = 0, 0, True
while len(aa) != 0:
    if is_a:
        a += aa.pop(-1)
        is_a = False
    else:
        b += aa.pop(-1)
        is_a = True

print(a-b)

# Example run
# Input:
-16240
1637046672
# Output:
1637046672
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
Alice = sum([a[i] for i in range(0, N, 2)])
Bob = sum(a) - Alice
print(Alice - Bob)


# Example run
# Input:
0
-82547695
# Output:
82547695
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:
-48
465
# Output:
0
alice=0
bob=0
n=int(input())
a=list(map(int,input().split()))
def delete():
    del a[a.index(Max)]
while n>=1:
    Max=max(a)
    alice=alice+Max
    n=n-1
    delete()
    if n>=1:
        Max=max(a)
        bob=bob+Max
        n=n-1
        delete()
else:
    print(alice-bob)



# Example run
# Input:
0
805965556
# Output:
0
n = map( int, input())
a = list(map( int, input().split() ))
A_point = 0
B_point = 0
flag = 1

a.sort(reverse=True)

for point in a:
    if flag%2 == 1:
        A_point += point
        flag += 1
    elif flag%2 == 0:
        B_point += point
        flag += 1

print("{}".format(A_point-B_point))

# Example run
# Input:
A9?b;/#NX
176191212
# Output:
176191212
N = int(input())
arr = list(map(int, input().split()))
arr.sort()
print(abs(sum(arr[1::2]) - sum(arr[::2])))


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

alice = 0
bob = 0
a.sort(reverse=True)
for i, v in enumerate(a):
    if i % 2 == 0:
        alice += v
    else:
        bob += v
print(alice - bob)


# Example run
# Input:
-331
18
# Output:
18
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:
-163
4554
# Output:
0
n=int(input())
a=list(map(int,input().split()))
a.sort()
s=0
for i in range(n):
  if n%2==0:
    if i%2==0:
      s+=a[i]
  else:
    if i%2!=0:
      s+=a[i]

print(sum(a)-s*2)

# Example run
# Input:
-5363
1552
# Output:
1552
N = int(input())
a_s = [int(x) for x in input().split()]

a_s.sort()
a_s.reverse()
alice = 0
bob = 0
for i, a in enumerate(a_s):
    if i % 2 == 0:
        alice += a
    else:
        bob += a
ans = alice - bob

print(ans)


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

# Example run
# Input:
25630
13
# Output:
13
N = int(input())
a_i = list(map(int, input().split(" ")))
 
x = []
y = []
 
if N%2==0:
    for j in range(int(N/2)):
        x.append(max(a_i))
        a_i.remove(max(a_i))
        y.append(max(a_i))
        a_i.remove(max(a_i))
 
else:
    for j in range(int((N/2)+1)):
        x.append(max(a_i))
        a_i.remove(max(a_i))
        if a_i == []:
            break
        y.append(max(a_i))
        a_i.remove(max(a_i))
 
X = sum(x)
Y = sum(y)
 
 
if X >= Y:
    print(X - Y)
 
else:
    print(Y - X)

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

alice = []
bob = []

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

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

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

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


# Example run
# Input:
57712056
374
# Output:
374
import math

input()
data = sorted(map(int, input().split(' ')))


s = 0
for i, n in enumerate(data):
    s = s + int(math.pow((-1),(i%2)))*n
print(s)

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

# Example run
# Input:
-236387597
-1005
# Output:
-1005
n = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)

Alice = A[::2]
Bob = A[1::2]

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

# Example run
# Input:
1593280440
2
# Output:
2
N = int(input()) 
card = [int(i) for i in input().split()] 
card.sort(reverse=True)
alice = 0
bob = 0
for i in range(0,N):
    if(i&1):
        #print(card[i])
        bob+=card[i]
    else:
        #print(card[i])
        alice+=card[i]
ans = alice - bob
print(ans)
    

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

li.sort()
li.reverse()
ans=0

for (i,c)in zip(range(0,n),li):
  if i%2==0:
    ans+=c
  else:
    ans-=c

print(ans)

# Example run
# Input:
-3022
-12962
# Output:
0
"""abc088_b"""
N = int(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)


# Example run
# Input:
665
-3123902
# Output:
-3123902
N=int(input())
table=list(map(int,input().split()))
alice_num=0
bob_num=0
table=sorted(table)
for i in range(N-1,-1,-1):
    if N%2==0:
        if i%2==1:
            alice_num+=table[i]
        else:
            bob_num+=table[i]
    else:
        if i%2==1:
            bob_num+=table[i]
        else:
            alice_num+=table[i]

print((alice_num)-(bob_num))


# Example run
# Input:
-11
-900588730
# Output:
0
def resolve():
    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)
resolve()

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

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

for i in range(N):
    for j in range(N-1,i,-1):
        if a[j] < a[j-1]:
            a[j], a[j-1] = a[j-1], a[j]

if N % 2 == 0:
    for k in range(N//2):
        Alice += a[(2*k)+1]
        Bob += a[2*k]
        

else:
    for k in range(N//2):
        Alice += a[2*k]
        Bob += a[2*k+1]
    Alice += a[N-1]

print(Alice-Bob)


# Example run
# Input:
-29792
-24296024
# Output:
0
n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)

alice = 0
bob = 0

for i in range(0, n, 2):
    alice += l[i]

for i in range(1, n, 2):
    bob += l[i]

print(alice - bob)


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

sum = 0
for i in range(len(s)):
  if i%2 == 0:
    sum += s[i]
  else:
    sum -= s[i]
print(sum)

# Example run
# Input:
Tiv&Q
-24166826
# Output:
-24166826
n = int(input())
A = sorted(list(map(int,input().split())))
A_card = []
B_card = []
for i in range(n):
        if i%2 == 0:
                A_card.append(A[i])
        else:
                B_card.append(A[i])
print(sum(A_card) - sum(B_card))

# Example run
# Input:
-3161926
-54
# Output:
0
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
alice = sum([i for i in a if i%2 == 0])
bob = sum([i for i in a if i%2 == 1])
print(alice-bob)


# Example run
# Input:
-62350830
260615611
# Output:
-260615611
N = int(input())
a = list(map(int, input().split()))
sorted_a = list(reversed(sorted(a)))
alice = 0
bob = 0
for i in range(N):
    if i % 2 == 0:
        alice += sorted_a[i]
    else:
        bob += sorted_a[i]
print(alice - bob)

# Example run
# Input:
-1967846
1036536343
# Output:
0
N = int(input())
itemList = input().split(' ')
hoge = []
for i in itemList:
    hoge.append(int(i))
hoge.sort()
hoge.reverse()

A = 0
B = 0

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

print(A-B)


# Example run
# Input:
-436344399
-83
# Output:
0
n = int(input())
cards = sorted(list(map(int, input().split())), reverse=True)

if n > 1:
    print(sum(cards[::2])-sum(cards[1::2]))
else:
    print(cards[0])

# Example run
# Input:
665422
14319043
# Output:
14319043
n = int(input())
a = [int(s) for s in input().split()]

alice = 0
bob = 0

a.sort(reverse=True)

turn = "alice"

for p in a :
    if turn == "alice" :
        alice = alice + p
        turn = "bob"
    elif turn == "bob" :
        bob = bob + p
        turn = "alice"

print(str(alice - bob))

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

a.sort()
a = a[::-1]
for i in range(n):
    c = c + ((-1)**(i%2))*a[i]

print(c)

# Example run
# Input:
-15303
-412794
# Output:
0
N = int(input())
cards = sorted(list(map(int, input().split())), reverse=True)
A, B = 0, 0
for idx in range(N):
  if idx % 2 == 0:
    A += cards[idx]
  else:
    B += cards[idx]
print(A - B)

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

# Example run
# Input:
52
-436344399
# Output:
436344399
n = int(input())
an = list(reversed(sorted(map(int,input().split()))))
print(sum(an[::2])-sum(an[1::2]))


# Example run
# Input:
730495
0
# Output:
0
N=int(input())

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


A.sort()
A.reverse()

Alice=0
Bob=0

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

        
gap=Alice-Bob
print(gap)


# Example run
# Input:
-11989124
-407
# Output:
0
n = int(input())
a = list(map(int, input().split()))

a.sort(reverse=True)

cnt = 0
Alice = 0
Bob = 0
while cnt < n:
    cnt += 1
    if cnt % 2 != 0:
        Alice += a[cnt-1]
    else:
        Bob += a[cnt-1]

print(Alice - Bob)


# Example run
# Input:
0
90
# 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:
380581
8
# Output:
8
N=int(input())
a=[int(i) for i in input().split()]

a.sort()
a.reverse()

ans1=0
ans2=0

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


# Example run
# Input:
-2540
-1836
# Output:
0
X = int(input())
A = list(map(int, input().split()))
list.sort(A, reverse=True)
B=0
C=0
ans = 0
for i,j in enumerate(A):
    if (i+1)%2 != 0:
        B+=j
    else :
        C+=j
ans = B-C
print(ans)
    




# Example run
# Input:
19928
129445
# Output:
129445
n = int(input())
an = list(map(int, input().split()))

alice = 0
bob = 0
an.sort()
an.reverse()
print(an)
for i,v in enumerate(an):
    if i % 2 ==0:
        alice += v
    else:
        bob += v

print(alice - bob)


# Example run
# Input:
-9283
-3436885
# Output:
[-3436885]
-3436885
N = int(input())
m = list(map(int,input().split()))
m = sorted(m,reverse=True)

ans = sum(m[::2])-sum(m[1::2])
print(ans)

# Example run
# Input:
-1
30456987
# Output:
30456987
Num = int(input())
Num_Array = sorted(list(map(int,input().split())),reverse=True)
Alice,Bob = 0,0

for i in range(Num):

    if i % 2 == 0 :
        Alice += Num_Array[i]
    else:
        Bob   += Num_Array[i]

print(Alice - Bob)

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

a = sorted(a)[::-1]

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

# Example run
# Input:
410684364
810667242
# Output:
810667242
num = int(input())
st = list(map(int,input().split()))
flag = True
all1 = 0
all2 = 0
for i in range(num):
  if flag == True:
    sum1 = max(st)
    st.remove(sum1)
    all1 = all1 + sum1
    flag = False
  else:
    sum1 = max(st)
    st.remove(sum1)
    all2 = all2 + sum1
    flag = True

print(all1-all2)

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


#順番にリスト内の最大値を抜き出し、それぞれのリストに順に格納

#それぞれのリストを作成
Alice_list = []
Bob_list = []

while True:

    #最大値を特定し要素番号を抜き出す
    max_idx = a_i.index(max(a_i))

    #最大値の値を抜き出し、リストからその値を削除
    Alice_list.append(a_i[max_idx])
    a_i.remove(a_i[max_idx])

    #リスト内が空になったら処理終了
    if len(a_i)==0:
        break
        
        
    #最大値を特定し要素番号を抜き出す
    max_idx = a_i.index(max(a_i))

    #最大値の値を抜き出し、リストからその値を削除
    Bob_list.append(a_i[max_idx])
    a_i.remove(a_i[max_idx])

    #リスト内が空になったら処理終了
    if len(a_i)==0:
        break
    
#Aliceの合計
Alice_sum = sum(Alice_list)

#Bobの合計
Bob_sum = sum(Bob_list)

#2人の差
Alice_Bob = Alice_sum - Bob_sum

#出力
print(Alice_Bob)

# Example run
# Input:
-13
367856
# Output:
367856
# coding=utf-8

if __name__ == '__main__':
    N = int(input())
    a = list(map(int, input().split()))

    a.sort(reverse=True)

    A = 0
    B = 0

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

    print(A - B)





# Example run
# Input:
-696034559
-16
# Output:
0
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:
0
-54266464
# Output:
-54266464
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
ali = []
bob = []
for i in range(n):
    if i % 2 == 0:
        ali.append(a[i])
    else:
        bob.append(a[i])

print(sum(ali)-sum(bob))

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

a.sort(reverse=True)

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

print("{}".format(Alice - Bob))

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

# Example run
# Input:
-1504387
31
# Output:
31
input()

As = sorted([int(a) for a in input().split()], reverse=True)
alice = sum([a if i % 2 == 0 else 0 for i, a in enumerate(As)])

print(alice - (sum(As) - alice))

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

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

# Example run
# Input:
9'r
-22
# Output:
22
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:
-101281970
-210
# Output:
-210
N = int(input())
card = [int(i) for i in input().split()]
card = sorted(card,reverse = True)
ans = 0
for i in range(N):
  if i % 2 == 0:
    ans += card[i]
  else:
    ans -= card[i]
  
print(ans)


# Example run
# Input:
-1759593
-6
# Output:
0
n=int(input())
al=list(map(int,input().split()))
al.sort(reverse=True)
alice=0
bob=0
flg=True
for a in al:
    if flg:
        alice+=a
    else:
        bob+=a
    flg=False if flg else True
print(alice-bob)

# Example run
# Input:
-746
-63
# Output:
-63
N = int(input())
score = list(map(int, input().split()))
total = 0
 
score.sort(reverse=True)
for i in range(0, N, 2):
  if i == N-2 or i == N-1:
    total = total + score[i]
  else:
    total = total + (score[i]-score[i+1])
 
print(total)

# Example run
# Input:
-398
986892
# Output:
0
N=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
flag=0
A=0
B=0
for i in a:
  if flag==0:
    A+=i
    flag=1
  else:
    B+=i
    flag=0
print(A-B)

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

# Example run
# Input:
(1bulQ!Z
-960
# Output:
-960
# coding=utf-8

N = int(input())
a = []

for x in input().split(" "):
    a.append(int(x))

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:
-1
10525264
# Output:
0
n = int(input())

num_list = [ int(v) for v in input().split() ]

a_sum, b_sum = 0, 0

for i in range(n):
  if i % 2 == 0:
    a_sum += num_list[i]
  else:
    b_sum += num_list[i]

print(a_sum - b_sum)

# Example run
# Input:
-1068
977
# Output:
0
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:
-740
1
# Output:
0
n = int(input())
a = sorted(list(map(int, input().split())), reverse = True)
d = 0
for i in range(n):
    d += a[i] * (-1 if i & 1 else 1)
print(d)


# Example run
# Input:
0
1
# Output:
0
N = int(input())
Ai = input().split()
Ai = [int(n) for n in Ai]
Ai = sorted(Ai, reverse=True)
Alice = 0
Bob = 0
i = 0
while True:
  if i+1 <= N:
    Alice += Ai[i]
    Bob = Alice[i+1]
  if i == N:
    Alice += Ai[i]
  if i > N:
    break
  i = i + 2

print(Alice - Bob)
    

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

# Example run
# Input:
-38
-17
# Output:
0
input()
A = list(map(int, input().split()))
A.sort(reverse=True)
print(sum([A[i] * ((-1) ** (i % 2)) for i in range(len(A))]))

# Example run
# Input:
;9WR=,
6442089
# Output:
6442089
n = int(input())
l = sorted(map(int, input().split()), reverse = True)

alice = 0
bob = 0
ab = False
for i in l:
  if ab == False:
    alice += i
    ab = True
  else:
    bob += i
    ab = False
    
print(alice - bob)
  

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

# Example run
# Input:
5
9
# Output:
9
n = int(input())
a = list(map(int, input().split()))

a.sort(reverse=True)
score_of_alice = score_of_bob = 0
for i, a_i in enumerate(a):
    if i % 2 == 0:
        score_of_alice += a_i
    else:
        score_of_bob += a_i

print(score_of_alice - score_of_bob)


# Example run
# Input:
1
-755
# Output:
-755
n=int(input())
L=[int(i) for i in input().split()]
print(2*sum(sorted(L)[::-2])-sum(L))

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

# Example run
# Input:
0
-31
# 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:
19487
-126312
# Output:
-126312
# ABC 88, B - card game for two
n = int(input())
A = [int(el) for el in input().split(' ')]

alice = 0
bob = 0
for i in range(n):
    if i % 2 == 0:
        alice += max(A)
    else:
        bob += max(A)
    A.remove(max(A))
print(alice - bob)


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


# Example run
# Input:
139893
5182
# Output:
5182
N = int(input())
cards = list(map(int, input().split()))
cards.sort(reverse=True)

Alice = 0
Bob = 0
for i, card in enumerate(cards):
    if i % 2 == 0:
        Alice += card
    else:
        Bob += card
print(Alice - Bob)

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

# Example run
# Input:
)B=
-194151326
# Output:
-194151326
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 27 21:41:45 2019

@author: yuta
"""

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

def main(a):
        card = sorted(a,reverse = True)
        Alice = sum(card[::2])
        Bob = sum(card[1::2])
        print(Alice - Bob)

main(a)

# Example run
# Input:
-1
-3439167
# Output:
-3439167
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
print(Alice - Bob)

# Example run
# Input:
32
-1
# Output:
-1
N=int(input())
lists = list(map(int,input().split()))
lists.sort(reverse = True)



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

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

# Example run
# Input:
-224852
-318594
# Output:
0
N = int(input())
li = list(map(int,input().split()))
a = []
b = []

li.sort(reverse = True)
for i in li[0::2]:
  a.append(i)
for i in li [1::2]:
  b.append(i)
print(sum(a) - sum(b))

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


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

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

# Example run
# Input:
jM|>j
-1477
# Output:
-1477
card_n = int(input())
card_collection = list(map(int, input().split()))

scores = {"alice" : 0, "bob" :0}
card_collection.sort(reverse = True)
for i, card in enumerate(card_collection):
    if i % 2 == 0:
        scores['alice'] += card
    else:
        scores['bob'] += card
print(scores["alice"] - scores["bob"])

    

# Example run
# Input:
112
6
# Output:
6
n = int(input())
A = [int(i) for i in 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:
-1
-3439167
# Output:
0
N = int(input())
nums = list(map(int, input().split()))

total = 0

while nums:
    total += max(nums)
    nums.remove(max(nums))
    if nums:
        total -= max(nums)
        nums.remove(max(nums))

print(total)


# sample
##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:
139
-42245
# Output:
-42245
N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
if N == 1:
  print(A[0])
  exit()
print(sum(A[0::2]) - sum(A[1::2]))

# Example run
# Input:
4
346
# Output:
346
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
a.reverse()
ans = sum(a[0:len(a):2]) - sum(a[1:len(a):2])
print(ans)

# Example run
# Input:
19487
-126312
# Output:
-126312
n = int(input())
a = list(map(int,input().split()))
a.sort()
i = len(a) - 1
fl = True
sumal = 0
while(i >= 0):
    if fl:
        sumal += a[i]
        fl = False
    else:
        sumal -= a[i]
        fl = True
    i -= 1
print(sumal)

# Example run
# Input:
-23909
-68
# Output:
-68
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

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


# Example run
# Input:
41
-97
# Output:
-97