Felix6326727/beyond-accuracy-code-comprehension huggingface dataset:
n=input()
a=sorted(list(map(int,input().split())),reverse=True)
print(sum(a[0::2])-sum(a[1::2]))

# Example run
# Input:
Pvi@_0
57223618
# Output:
57223618
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:
-150069
470
# Output:
470
n = int(input())
a = sorted(list(map(int, input().split())))[::-1]
A = 0
B = 0

for i in a [::2]:
    A += i
for i in a [1::2]:
    B += i

print(A - B)

# Example run
# Input:
-58138
-607
# Output:
-607
n = int(input())
a = list(map(int, input().split()))
print(a)
count = 0
alice = 0
bob = 0
a.sort()
f = 0
while(len(a) != 0):
    if f == 0:
        alice = alice + a.pop(-1)
        f = 1
    else:
        bob = bob + a.pop(-1)
        f = 0
print('alice %d' % alice)
print('bob %d' % bob)
print(alice - bob)


# Example run
# Input:
587245588
3185105
# Output:
[3185105]
alice 3185105
bob 0
3185105
n = int(input())
data = list(map(int,input().split()))
data = sorted(data, reverse=True)
alice = 0
bob = 0
for i,var in enumerate(data):
    if i%2 == 0:    
        alice += var
    else:    
        bob += var
print(alice-bob)        

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

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

# Example run
# Input:
6191986
-10
# Output:
-10
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:
-202544
1700749
# Output:
1700749
_ = input()
cards = map(int, input().split())
cards = sorted(cards)[::-1]

a = sum(cards[0::2])
b = sum(cards[1::2])

print(a-b)

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

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

alice = 0
bob = 0

for i in range(n + 1):
    max_index = a.index(max(a))

    if i % 2 == 0:
        alice += max(a)

    else:
        bob += max(a)

    a[max_index] = 0

print(alice - bob)

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

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

# Example run
# Input:
-2147483648
-1406309
# Output:
0
N = int(input())

#mapの使い方
#map(functon,sequence_object)
#第一引数が関数第二引数がシーケンス
#mapを使うと一つの要素に対する処理をリスト全体に対して行ってくれる
#input.splitではinput（入力）をスペース区切りのリストにしている。その要素に対してmapで数字をintに変換

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

#降順にソート
l.sort(reverse=True)

#スライスの使い方l(strt:stop:step)
#strt,stopは0から始まる
print(sum(l[0::2]) - sum(l[1::2]))



# Example run
# Input:
-4868286
-104837
# Output:
-104837
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
aa=0
bb=0
x=-1
while x>=-n:
    if x%2==0:
        bb+=a[x]
    else:
        aa+=a[x]
    x-=1
print(aa-bb)

# Example run
# Input:
-93
-114886
# Output:
0
# ABC088 B Card Game for Two
def main():
    n = int(input().strip())
    a = [int(x) for x in input().split()]

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

    print(alice - bob)
    

if __name__ == '__main__':
    main()


# Example run
# Input:
28210012
7348
# Output:
7348
N = input()
A = list(input().split())
A = list(map(int,A))
A = sorted(A,reverse = True)
a = 0
b = 0
try :
  while len(A) != 0 :
    a += A.pop(0)
    b += A.pop(0)
except IndexError :
  print(a-b)
print(a-b)

# Example run
# Input:
e3zvshd]
45580
# Output:
45580
45580
n = int(input())
card_list = list(map(int, input().split()))

alice_point = 0
bob_point = 0

def pick_card(card_list):
    # print(card_list)
    max = 0
    max_index = 0
    for i in range(card_list.__len__()):
        # print('-------', i)
        if card_list[i] > max:
            # print('@', i, ':', max, '<', card_list[i])
            max = card_list[i]
            max_index = i
    
    del card_list[max_index]

    # print('----', card_list)

    return max, card_list

def sort_card(card_list: list):
    return sorted(card_list)

turn = 0
while turn < n:
    # print('--', turn)
    sorted_list = sort_card(card_list)
    if turn % 2 == 0:
        # alice_get, remain_list = pick_card(card_list)
        # alice_point += alice_get
        alice_point += sorted_list.pop()
    else:
        # bob_get, remain_list = pick_card(card_list)
        # bob_point += bob_get
        bob_point += sorted_list.pop()

    # card_list = remain_list
    # print(alice_point, bob_point, card_list)

    turn += 1

print(alice_point - bob_point)


# Example run
# Input:
-22340
-10884483
# Output:
0
n = int(input())
arr = list(map(int, input().split()))

for i in range(0, len(arr)-1):
    for j in range(i+1, len(arr)):
        if arr[i]<arr[j]:
            buf = arr[i]
            arr[i] = arr[j]
            arr[j] = buf

sa = 0
sb = 0
for i in range(0, len(arr)):
    if i % 2 == 0:
        sa += arr[i]
    else:
        sb += arr[i]
print(sa - sb)


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

a = 0
b = 0
for i in range(0,N,2):
  a += A[i]
for i in range(1,N,2):
  b += A[i]
print(a-b)

# Example run
# Input:
0
4081983
# 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:
5343
26551053
# Output:
26551053
n = int(input())
src = list(map(int, input().split()))
a = 0
b = 0
srt = sorted(src, reverse=True)
for i,s in enumerate(srt):
    if i%2 == 0:
        a += s
    else:
        b += s
print(a-b)


# Example run
# Input:
26131
1748
# Output:
1748
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:
ig(wme[3g
2147483647
# Output:
2147483647
input()
ai = [int(i) for i in input().split(" ")]
ai.sort()
ai = tuple((j ,a) for j,a in enumerate(reversed(ai)))
alice=sum([ a for j,a in list(filter(lambda x: x[0]%2 == 0, ai))])
bob=sum([ a for j,a in list(filter(lambda x: x[0]%2 == 1, ai))])
print (alice - bob)

# Example run
# Input:
UFy~R:?b
104
# Output:
104
N = int(input())
A = list(map(int, input().split()))

Alice = 0
Bob = 0
A.sort(reverse=True)
for i, a in enumerate(A):
	if i%2 == 0: Alice += a
	else : Bob += a

print(Alice-Bob)

# Example run
# Input:
7987516
0
# Output:
0
N=int(input())
a=[int(i) for i in input().split()]
a.sort()
c=a[0::2]
e=sum(c)
d=a[1::2]
f=sum(d)
print(abs(f-e))

# Example run
# Input:
-473
-7
# Output:
7
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:
-2147483648
1940
# Output:
0
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]

ans = Alice - Bob
print(ans)


# Example run
# Input:
0
90
# Output:
0
n = int(input())
lis = list(map(int, input().split()))
lis = sorted(lis)
alice = 0
bob = 0
for i, value in enumerate(lis):
    if i % 2 != 0:
        alice += value
    else:
        bob += value
print(abs(alice - bob))

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

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

# Example run
# Input:
-5654
161
# Output:
161
N = int(input())
cardList = [int(i) for i in input().split()]

cardList.sort(reverse=True)

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


# Example run
# Input:
380581
8
# Output:
8
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:
-48655
32683
# Output:
0
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)
print(b)

# Example run
# Input:
184
19524
# Output:
19524
[19524]
def main():
    N = int(input())
    A = [int(n) for n in input().split()]

    A = sorted(A, reverse=True)
    Alice = 0
    Bob = 0
    for i, a in enumerate(A):
        if i % 2 == 0:
            Alice += a
        else:
            Bob += a
    print(Alice - Bob)


main()


# Example run
# Input:
113162947
-2540
# Output:
-2540
N = int(input())
card_values = list(map(int, input().split(" ")))

card_values_sorted = sorted(card_values, reverse=True)
print(card_values_sorted)

Alice_score = 0
Bob_score = 0
for i in range(N):
    if i%2 == 0:
        Alice_score += card_values_sorted[i]
    else:
        Bob_score += card_values_sorted[i]

print(Alice_score - Bob_score)

# Example run
# Input:
-39355
1
# Output:
[1]
0
N = int(input())

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

a.reverse()

A = []
B = []

for x in range(0,N+1,2):
    A.append(a[x])

for y in range(1,N,2):
    B.append(a[y])
    

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

# Example run
# Input:
-3108573
51
# Output:
0
CARD_NUM = int(input())
RAW_CARDS = input().split(' ')

card_array = [int(raw_card) for raw_card in RAW_CARDS]
card_array.sort(reverse=True)

alice_cards = list()
bob_cards = list()

is_alice = True

for card in card_array:
    if is_alice:
        alice_cards.append(card)
    else:
        bob_cards.append(card)
    is_alice = not is_alice

print(sum(alice_cards) - sum(bob_cards))


# Example run
# Input:
0
-84521052
# Output:
-84521052
input()

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

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

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


# Example run
# Input:
-4868286
-104837
# Output:
-104837
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
#N, K = map(int, input().split())
N=int(input())
# 文字列の入力
s = input()
a=s.split(' ')
a=list(map(int,a))
a=sorted(a)
a.reverse()
flg=1
ans=0
for i in a:
    ans = ans + (i*flg)
    flg = flg*-1
print(ans)
#print(s[0:K-1]+s[K-1].lower()+s[K:N])


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

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

alice = 0
bob = 0
count = 0

a.sort(reverse = True)

for i in a:
    if count%2 == 0:
        alice += i
    else:
        bob += i
    count += 1

print(alice - bob)


# Example run
# Input:
12270
810667242
# Output:
810667242
N = int(input())
a = list(map(int, input().strip().split(' ')))
sorted_a = sorted(a, reverse=True)

Alice = 0
Bob = 0
while not sorted_a == []:
  Alice += sorted_a[0]
  sorted_a.pop(0)
  if sorted_a == []:
    break
  Bob += sorted_a[0]
  sorted_a.pop(0)

print(Alice - Bob)

# Example run
# Input:
-1201474778
113
# Output:
113
n = int(input())
list_a = list(map(int, input().split()))
list_a.sort(reverse=True)
list_alice = [a for i, a in enumerate(list_a) if i % 2 == 0]
list_bob = [a for i, a in enumerate(list_a) if i % 2 != 0]
print(sum(list_alice) - sum(list_bob))

# Example run
# Input:
55
4
# Output:
4
n = int(input())
a = list(map(int,input().split()))
l = sorted(a, reverse=True)

ans = 0
for i in range(n):
    if i % 2 == 0:
        ans += l[i]
    else:
        ans -= l[i]

print(ans)

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

# Example run
# Input:
-5403886
3294212
# Output:
[3294212]
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:
-2147483648
-3528
# Output:
-3528
N = int(input())
a = list(map(int, input().split()))

Alice = 0
Bob = 0
for i in range(N):
    ai=max(a)
    if i%2:
        Bob+=ai
    else:
        Alice+=ai
    a.remove(ai)

print(Alice-Bob)

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

# Example run
# Input:
60
30291214
# Output:
30291214
N=int(input())
card=sorted(list(map(int,input().split())),reverse=True)
A=sum([i for x,i in enumerate(card) if x%2])
B=sum([i for x,i in enumerate(card) if not x%2])
print(abs(A-B))

# Example run
# Input:
0
35
# Output:
35
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
sum1=0
sum2=0
for num in range(N):
  if num % 2 == 0:
    sum1 += A[num]
  else:
    sum2 += A[num]
print(sum1 - sum2)

# Example run
# Input:
-126905272
28016
# Output:
0
# ABC088 B

def main():
    n = int(input())
    A = list(map(int, input().split()))

    Alice = 0
    Bob = 0
    A_sorted = sorted(A)[::-1]

    for i in range(n):
        if i % 2:
            Bob += A_sorted[i]
        else:
            Alice += A_sorted[i]
    
    print(Alice - Bob)

if __name__ == '__main__':
    main()

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

a.sort(reverse = True)
alice_score = 0
bob_score = 0
for i in range(n):
	if i % 2 == 0:
		alice_score += a[i]
	else:
		bob_score += a[i]
print(alice_score - bob_score)

# Example run
# Input:
-14
1949
# Output:
0
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:
-104837
-69520
# Output:
0
n = int(input())
ls = list(map(int, input().split()))
ls.sort()
ls.reverse()
lsa = []
lsb = []
for i in range(n):
    if i // 2 == 0:
        lsa += [ls[i]]
    else:
        lsb += [ls[i]]
a = sum(lsa)
b = sum(lsb)
c = a - b
print(c)


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

l.sort(reverse=True)

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


# Example run
# Input:
-133790981
215616622
# Output:
0
n = input()
li = list(map(int,input().split()))
li.sort(reverse=True)
Alice = 0
Bob = 0
count = 1
for i in li:
    if count % 2:
        Alice += i
        count += 1
    else:
        Bob += i
        count += 1
print(Alice - Bob)




# Example run
# Input:
Q_"A[
9850811
# Output:
9850811
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:
-362516271
0
# Output:
0
N = int(input())
A = list(map(int,input().split()))
A.sort()
A.reverse()
L = []
M = []
for i in range(len(A)):
  if (i % 2 == 0):
    L.append(A[i])
  else:
    M.append(A[i])
print(sum(L)-sum(M))

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

# Example run
# Input:
<+c9'r
-22
# Output:
-22
"""abc088_b"""
N = input()
a = sorted(list(map(int, input().split())), reverse=True)
print(sum(a[0::2])-sum(a[1::2]))


# Example run
# Input:
RQG
-2040
# Output:
-2040
# 標準入力
num = int(input())
data = list(map(int, input().split()))

# 初期化
alice = 0
bob = 0

# 降順にソート
data = sorted(data, reverse=True)

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

print(alice - bob)

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

#1番目に大きいもの、3番目に大きいもの....の和から、2番目に大きいもの、4番目に大きいもの...を引く

# Example run
# Input:
aY2(6Is@8
-168854
# Output:
-168854
n=int(input())
a=list(map(int, input().split()))

a.sort()
alice=0
bob=0

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

for i in range(n//2):
    bob+=a[-2-2*i]

if n%2!=0:
    alice+=a[0]


print(alice-bob)

# Example run
# Input:
0
-62124928
# Output:
0
N = int(input())
Ai = list(map(int,input().split()))
Ai.sort(reverse=True)
Alice = 0
for w in range(0,len(Ai),2):
    Alice = Alice + Ai[w]
for w in range(1,len(Ai),2):
    Alice = Alice - Ai[w]
print(str(Alice))


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

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

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

# Example run
# Input:
-108
624906
# Output:
0
N = int(input())
list_a = list(map(int, input().split()))

Alice_score = 0
Bob_score = 0

while len(list_a) > 0:
    Alice_score += list_a.pop(list_a.index(max(list_a)))
    if len(list_a) > 0:
        Bob_score += list_a.pop(list_a.index(max(list_a)))

print(Alice_score - Bob_score)

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

# Example run
# Input:
55692629
-70037
# Output:
-70037
N = int(input())
li = list(map(int,input().split()))
Alice = []
Bob = []

li=sorted(li,reverse=True)
for i in range(N):
    if i%2 == 0:
        Alice.append(li[i])
    else:
        Bob.append(li[i])
print(sum(Alice)-sum(Bob))

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


# Example run
# Input:
7t4EP
-80
# Output:
-80
N=input()
A=sorted(list(map(int,input().split())),reverse=True)

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

# Example run
# Input:
<&wJ
1294
# Output:
1294
n = int(input())
a = list(map(int,input().split()))
suma = 0
sumb = 0
a.sort(reverse = True)
 
for i in range(len(a)):
  if i%2 == 0:
    suma += a[i]
  else:
    sumb += a[i]
    
print(suma-sumb)

# Example run
# Input:
-252699780
988493674
# Output:
988493674
n=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
Alice=[A[i] for i in range(0,n,2)]
Bob=[A[j] for j in range(1,n,2)]
print(sum(Alice)-sum(Bob))


# Example run
# Input:
-1799682701
446
# Output:
0
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:
-2811762
15761764
# Output:
0
N = int(input())
A = [int(x) for x in input().split()]
Alice =0
Bob = 0
A.sort()
A.reverse()
for i in range(0,N,2):
  Alice +=A[i]
Bob =sum(A)-Alice
print(Alice-Bob)

# Example run
# Input:
-1406309
-967
# Output:
967
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:
-330000948
-8
# Output:
0
n = int(input())
a = [int(s) for s in input().split()]
a.sort(key=int,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
5568815
# Output:
0
n = int(input())
a = list(reversed((sorted((map(int, input().split()))))))
#a = list(reversed(sorted(a)))

alice = 0
bob = 0

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

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


# Example run
# Input:
-1654029
-3
# Output:
3
N = int(input())
nums = list(map(int, input().split()))
nums.sort(reverse=True)
cnt = 0
Alice = 0
Bob = 0
for n in nums:
    if cnt % 2 == 0:
        Alice += n
    else:
        Bob += n
    cnt += 1
print(Alice-Bob)


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

if n % 2:
    a.append(0)
aa = 0
bb = 0
for i in range(0,len(a),2):
    aa += a[i]
    bb += a[i+1]

print(aa-bb)

# Example run
# Input:
3320259
-2147483648
# Output:
-2147483648
n=int(input())
a=list(map(int,input().split()))
a.sort()
e=[]
b=[]
turn=1
for i in range(n):
    if turn==1:
        e.append(a.pop(-1))
        turn-=1
    else:
        b.append(a.pop(-1))
        turn+=1
print(sum(e)-sum(b))

# Example run
# Input:
-7930
-86
# Output:
0
N=input()
c=sorted(list(map(int,input().split())))[::-1]
n=0
for i in c[0::2]:
  n+=i
for i in c[1::2]:
  n-=i
print(n)

# Example run
# Input:
@(1
-507621088
# Output:
-507621088
# -*- coding: utf-8 -*-

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

Alice = 0
Bob = 0

Turn = 0
for a in sorted(A, reverse=True):
    if Turn == 0:
        Alice += a
        Turn =1
    else:
        Bob += a
        Turn = 0
print(Alice-Bob)


# Example run
# Input:
-3225
-5024207
# Output:
-5024207
N=int(input())
ai=input().split()
ai=list(map(int,ai))
list.sort(ai,reverse=True)
alice_number=ai[0::2]
bob_number=ai[1::2]
alice_tot=sum(alice_number)
bob_tot=sum(bob_number)
print(alice_tot-bob_tot)

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

a.sort(reverse=True)

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

print(ret)

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

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

# Example run
# Input:
13499019
3132478
# Output:
3132478
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:
-31
-58867430
# Output:
-58867430
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:
-1794
-1147387
# Output:
0
n = int(input())
li = list(map(int,input().split()))
#print(li)
li.sort(reverse = True)
#print(li)

sum_A = 0
sum_B = 0

for i in range(0,n,2):
	sum_A += li[i]
#print(sum_A)
for i in range(1,n,2):
	sum_B += li[i]
#print(sum_B)

print(sum_A-sum_B)

# Example run
# Input:
0
985477
# Output:
0
n = int(input())
Alice = 0
Bob = 0
card = list(map(int,input().split(' ')))
card.sort(reverse=True)
for i in range(n):
    num = card[i]
    if(i%2==0):
        Alice+=num
    else:
        Bob+=num

print((Alice-Bob))


# Example run
# Input:
-236387597
-1005
# Output:
0
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
res = 0
for i in range(N - 1, -1, -2):
    res += A[i]
for i in range(N - 2, -1, -2):
    res -= A[i]
print(res)


# Example run
# Input:
1
87
# Output:
87
N = int(input())
cards = list(map(int,input().split()))
cards_sort = sorted(cards,reverse = True)
Alice = 0
Bob = 0
for i in range(0,N,2):
    Alice += cards_sort[i]
for i in range(1,N,2):
    Bob += cards_sort[i]

ans  =Alice - Bob
print(ans)


# Example run
# Input:
-6325
1
# Output:
0
cards = [int(i) for i in input().split()]
cards.sort(reverse=True)

diff = 0

for idx, i in enumerate(cards):
	if idx % 2 == 0:
		diff += i
	else:
		diff -= i

print(diff)

# Example run
# Input:
11306
# Output:
11306
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
Alice, Bob = 0, 0

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

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

# Example run
# Input:
-536687537
-253690
# Output:
0