Felix6326727/beyond-accuracy-code-comprehension huggingface dataset:
n = int(input())
A = list(map(int, input().split()))
Alice = [0] * n
Bob = Alice[:]

A.sort(reverse = True)

for i in range(n):
    if i % 2 == 0:
        Alice[i] = A[i]
    else:
        Bob[i] = A[i]

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

# Example run
# Input:
-2314351
3986
# Output:
0
# B - Card Game for Two
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:
-989028
54353
# Output:
0
N = int(input())
a = list(map(int, input().split()))

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

# Example run
# Input:
-2239572
-31
# Output:
-31
n=int(input())
a=list(map(int,input().split()))
a2=sorted(a,reverse=True)
total=0
for i in range(1,n+1):
    if i%2==1:
        total+=a2[i-1]
    else:
        total-=a2[i-1]
print(total)

# Example run
# Input:
-221907
-154
# Output:
0
N = int(input())
a = list(map(int, input().split()))
a1 = sorted(a, reverse=True)
Alice = 0
Bob = 0
for i in range(N):
    if i % 2 == 0:
        Alice += a1[i]
    else:
        Bob += a1[i]
print(Alice - Bob)

# Example run
# Input:
-5
-64
# Output:
0
# -*- coding: utf-8 -*-

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

a_list.sort()
a_list.reverse()

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

    if i + 1 < len(a_list):
        bob += a_list[i + 1]

print(alice - bob)


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


# Example run
# Input:
7842
-19797306
# Output:
-19797306
N = int(input())
a = list(map(int, input().split()))
b = sorted(a, reverse=True)

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


# Example run
# Input:
-54634663
3615919
# Output:
3615919
N = int(input())
a = 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:
-420252
-128585
# Output:
0
N = int(input())

list = input().split()
list_int = [int(s) for s in list]
list_int.sort(reverse=True)

A = 0
B = 0

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

ans = A - B
print(ans)


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

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

# Example run
# Input:
-28028
-640183291
# Output:
-640183291
# -*- coding: utf-8 -*-
N = input()
list_N = list(map(int, input().split()))
list_N.sort(reverse=True)

alice_sum = sum(list_N[::2])
bob_sum = sum(list_N[1::2])

ans = alice_sum - bob_sum

print(ans)


# Example run
# Input:
e3zvshd]
45580
# Output:
45580
n=int(input())
a=list(map(int, input().split()))
a=sorted(a, reverse=True)
al=a[0::2]
print(sum(al)*2 - sum(a))

# Example run
# Input:
21643
-887384
# Output:
-887384
n = int(input())
a = [int(x) for x in input().split()]
a= sorted(a)
alice = sum(a[::2])
bob = sum(a[1::2])

print(abs(alice-bob))

# Example run
# Input:
-227170451
13499019
# Output:
13499019
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:
-68
-31
# 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:
-1138
-22588477
# Output:
-22588477
N = int(input())
A = list(map(int, input().split()))

score_a = 0
score_b = 0

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


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

# Example run
# Input:
2147483647
1
# Output:
1
N = input()
li = input().split()
li.sort(reverse=True)
t = 0
ans = 0
for i in li:
  if t % 2 == 0:
    ans += int(i)
  else:
    ans -= int(i)
  t += 1

print(ans)

# Example run
# Input:
xWAS`~
-255155
# Output:
-255155
N = int(input())
LIST = list(map(int, input().split()))
LIST.sort()
Bob = 0
Alice = 0

while True:
    if len(LIST) == 0:
        break
    Alice = Alice + LIST.pop()
    if len(LIST) == 0:
        break
    Bob = Bob + LIST.pop()

print(Alice - Bob)

# Example run
# Input:
9
313685
# Output:
313685
n=int(input())
a=list(map(int, input().split()))
if len(a) % 2 != 0 :
    a.append(0)
a=sorted(a, reverse=True)
al=a[0::2]
print(sum(al)*2 - sum(a))

# Example run
# Input:
-12503953
-345658
# Output:
345658
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:
-4868286
-104837
# Output:
-104837
N = int(input())
a = list(map(int,input().split()))
b = sorted(a, reverse=True) 
Alice = 0
Bob = 0

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



# Example run
# Input:
-838
150
# Output:
0
# coding: utf-8

num = int(input())
str = input().split()
table = [int(i) for i in str]

table2 = sorted(table, reverse = True)
a_point = 0
b_point = 0

for i in range(num):
    if i % 2 == 0:
        a_point += table2[i]
    elif i % 2 == 1:
        b_point += table2[i]
print(a_point - b_point)

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

# Example run
# Input:
374
-838
# Output:
-838
n = int(input())
list_a = list((map(int, input().split())))
list_a.sort()
list_alice = list_a[-1::-2]
if n == 1:
    list_bob = []
else:
    list_bob = list_a[-2::-2]
ans_alice = 0
ans_bob = 0
for number in list_alice:
    ans_alice += number
for number in list_bob:
    ans_bob += number
print(ans_alice - ans_bob)


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

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

# Example run
# Input:
-2260822
60
# Output:
60
N = int(input())
li = list(map(int,input().split()))
li.sort(reverse = True)
al = 0
bob = 0
for i in range(N):
  if i % 2 == 0:
    al = al + li[i]
  else:
    bob = bob + li[i]
an = al - bob
print(an)

# Example run
# Input:
-58077
647746204
# Output:
0
n=int(input())
a=sorted(map(int,input().split()),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:
-224231
-640183291
# Output:
0
n = input()
a = list(map(int, input().split()))
a= sorted(a, reverse=True)
print(a)
ans =0
for i in a:
    if i%2 == 0:
        ans += i
    elif i%2 ==1:
        ans -= i
print(ans)

# Example run
# Input:
:$hF
665
# Output:
[665]
-665
N = int(input())
cards = list(map(int, input().split()))

alice = 0
bob = 0
for i in range(N):
  if i % 2 == 0:
    alice += cards[i]
  else:
    bob += cards[i]

print(alice-bob)

# Example run
# Input:
-46095437
-5
# Output:
0
N = int(input())
scores = list(int(i) for i in input().split())

sorted_scores = sorted(scores)[::-1]
alice = sum(sorted_scores[::2])
bob = sum(sorted_scores[1::2])

print(alice - bob)


# Example run
# Input:
6
211
# Output:
211
N = int(input())
a_list = list(map(int, input().split()))

a_list_descend = sorted(a_list, reverse=True)

diff = sum(a_list_descend[0::2]) - sum(a_list_descend[1::2])

print(diff)


# Example run
# Input:
11
4082171
# Output:
4082171
n = int(input())
a = list(map(int,input().split()))
a.sort()
cnt = 0
sum1 = 0
sum2 = 0
for i in range(n):
	if cnt % 2 == 0:
		sum1 += a[i]
	else:
		sum2 += a[i]
print(sum1 - sum2)

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

a = 0
b = 0

for i, num in enumerate(l):
    if i % 2 == 0:
        a += num
    else:
        b += num

print(a-b)


# Example run
# Input:
-536687537
-253690
# Output:
-253690
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:
-3
7395
# Output:
0
N = int(input())
A = [int(x) for x in input().split()]
A.sort(reverse=True)
alice = sum(A[::2])
bob = sum(A[1::2])
print(alice-bob)

# Example run
# Input:
1
-2
# Output:
-2
n = int(input())
a = [int(i) for i in 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:
-2147483648
450137
# Output:
0
N = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
sum_Alice = 0
sum_Bob = 0
for i in range(N):
    if i % 2 == 0:
        sum_Alice += a[i]
    else:
        sum_Bob += a[i]
print(sum_Alice - sum_Bob)

# Example run
# Input:
-26772387
815
# Output:
0
N = int(input())
A = sorted([int(x) for x in input().split()], reverse = True)
print(sum(A[::2]) - sum(A[1::2]))


# Example run
# Input:
165
-316
# Output:
-316
n = int(input())
cards = list(map(int, input().split()))
sorted_cards = sorted(cards, reverse=True)

alice = sorted_cards[0::2]
bob = sorted_cards[1::2]

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


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

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

# Example run
# Input:
-504
9042
# Output:
9042
from functools import reduce 
from operator import add
 
n = int(input())
arr = list(map(int, input().split()))
 
pt_a = 0
pt_b = 0
 
arr.sort(reverse=True)
 
for ind, num in enumerate(arr):
  if ind % 2 == 0:
    pt_a += num
  else:
    pt_b += num
 
print(pt_a - pt_b)

# Example run
# Input:
4195951
98
# Output:
98
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
#print(a)
b=[]
c=[]
for i in range(0,n,2):
  b.append(a[i])
  c.append(a[i-1])
print(sum(b)-(sum(c)-c[0]))
  

# Example run
# Input:
1
-124978655
# Output:
-124978655
N = int(input())
A = list(map(int, input().split()))
Alice = 0
A.sort()
for i in range(0,N,2):
  Alice += A[i]
print(2*Alice - sum(A))

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

list=sorted(list)[::-1]
print(list)
A=0
B=0

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

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


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


# Example run
# Input:
3897539
-18099607
# Output:
-18099607
N = int(input())
A = list(reversed(sorted(list(map(int,input().split())))))
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:
-728818981
-2811762
# Output:
0
N = int(input())
li = list(map(int,input().split()))
li.sort(reverse=True)
Alice = 0
Bob = 0
for i in range(1,N+1):
    if i%2 !=0:
        Alice+=li[i-1]
    elif i%2 == 0:
        Bob += li[i-1]
ans = Alice-Bob
print(ans)

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

# Example run
# Input:
981571
-6163826
# Output:
-6163826
N = int(input())
a = list(map(int, input().split()))
sorted_a = 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:
-8
-39
# 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==1:
        A+=a[i]
    else:
        B+=a[i]
print(abs(A-B))

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

alice = 0
bob   = 0


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


print(alice - bob)


# Example run
# Input:
48477567
21507
# Output:
21507
N=input()

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

alice = 0
bob = 0

while True:
    try:
        alice += Ai.pop()
        bob += Ai.pop()
    except:
        break

print(alice - bob)

# Example run
# Input:
6ej=k^S/8
981571
# Output:
981571
n = int(input())
a = [int(x) for x in input().split()]
res = 0
for i in range(n):
  if i % 2 == 0:
    res += a[i]
  else:
    res -= a[i]
print(res)

# Example run
# Input:
-55649
-7038374
# Output:
0
n=int(input())
cardpoints=list(map(int,input().split()))

alicep=0
bobp=0

for i in range(n):
	if i%2 == 0:
		alicep += max(cardpoints)
		cardpoints.remove(max(cardpoints))
	else:
		bobp += max(cardpoints)
		cardpoints.remove(max(cardpoints))

print(alicep-bobp)

# Example run
# Input:
-6086
3280
# Output:
0
N = int(input())
a = [int(a) for a in input().split()]

sorted_a = sorted(a, reverse=True)

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

print(alice-bob)

# Example run
# Input:
-1595467139
3280
# Output:
3280
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:
-1141
0
# Output:
0
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
n=i1()
a=i2()
al=[]
bo=[]
a=sorted(a)
a=a[::-1]
for i in range(n):
 if i%2==0:
  al.append(a[i])
 else:
  bo.append(a[i])
print(sum(al)-sum(bo))

# Example run
# Input:
-3108573
51
# 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:
30315
-65
# Output:
-65
def main(N,xs):
    # type: (int, List[int]) -> None
    xs.sort()
    xs.reverse() # 降順
    alice = 0
    bob = 0
    for i,x in enumerate(xs):
        if i % 2 == 0:
            alice += x
        else:
            bob += x
    print(alice-bob)
    return

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


# Example run
# Input:
-35798645
-6
# Output:
-6
#カードの枚数N
N = int(input())

#カードに書かれる数a
a = list(map(int, input().split()))
a = sorted(a, reverse = True)

#print(N)
#print(a)

Alice = 0
Bob = 0

#ターン数x
x = 0

#pop(n) ➡　配列のn番目の要素を抜き取る
while not(len(a) == 0):
    if x%2 == 0:
        Alice += a.pop(0)

        #print(Alice)
        x += 1
        #a = [:a(max)]

    else:
        Bob += a.pop(0)
        #print(Bob)
        x += 1

print(Alice - Bob)

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

a = sorted(a)

ans = 0
flag = 1
for x in a:
  ans += x * flag
  flag *= -1

print(ans)

# Example run
# Input:
-46095437
-5
# Output:
-5
N = int(input())
ans = list(map(int, input().split()))

alice=0
bob=0
for _ in range(N):
    alice += max(ans)
    ans.remove(max(ans))
    if len(ans) == 0:
        break
    bob += max(ans)
    ans.remove(max(ans))
    if len(ans) == 0:
        break

print(alice - bob)

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

ali_sum = 0
bob_sum = 0

for index, card in enumerate(sorted(card_list)):
    if index % 2 == 1:
        ali_sum +=  card
    else:
        bob_sum += card

print(abs(ali_sum - bob_sum))

# Example run
# Input:
346
176397305
# Output:
176397305
n = input()
a = reversed(sorted(map(int, input().split())))

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

print(ans)


# Example run
# Input:
oau}Q!*
7987516
# Output:
7987516
input();c=0
for a in sorted(map(int,input().split())):c=a-c
print(c)

# Example run
# Input:
:u{kD)1)
58
# Output:
58
N = input()
a = sorted(list(map(int, input().split(" "))), reverse=True)

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

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

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

diff = 0
s = 1

while(len(c) > 0):
  diff = diff + (s * c.pop(c.index(max(c))) )
  s = s * -1

print(diff)

# Example run
# Input:
-1643990
363865392
# Output:
363865392
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
asum = 0
bsum = 0
for a in A[0::2]:
  asum += a
for a in A[1::2]:
  bsum += a
print(asum - bsum)


# Example run
# Input:
-579377
-21
# Output:
-21
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:
-91
0
# Output:
0
n = int(input())
li = list(map(int,input().split()))
li.sort()
sum = 0
al = 0
s = 0
for i in range(n):
    sum+=li[n-i-1]
    if ((i%2)==0):
        al +=li[n-i-1]
s = al -(sum -al)
print(s)

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

# Example run
# Input:
61070189
-2090237817
# Output:
-2090237817
# -*- coding: utf-8 -*-
a = int(input())  # Nを入力
b = input()  # a1,a2...anを入力
b = map(int, b.split())  # a1,a2...anをint型でリストに入れる
b = sorted(b)  # 大きい順に並べる b = b[::-1]  # リストの要素の順番を逆転する
c = b[::2]  # Aliceのとる要素を抽出
c_number = len(c)
d = b[1::2]  # Bobのとる要素を抽出
d_number = len(d)
c_sum = 0
d_sum = 0
for i in range(c_number):
    c_sum += c[i] # Aliceのとる要素の合計
for g in range(d_number):
    d_sum += d[g]  # Bobのとる要素の合計
print(c_sum - d_sum)  # 差分を出力


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

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


# Example run
# Input:
-907243029
-671
# Output:
-671
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:
1
13
# Output:
13
N = int(input())
A = list(map(int, input().split()))
A = sorted(A, reverse = True)
dif = sum(A[0::2]) - sum(A[1::2])
print(dif)


# Example run
# Input:
-5271130
19
# Output:
19
# 088 B
N = int(input())
a = list(map(int, input().split()))
A = 0
B = 0
aa = sorted(a)
for i in range(0, N, 2):
    A += aa[-i-1]
    if (i+2)<=N:
        B += aa[-i-2]
print(A-B)


# Example run
# Input:
-9071
21643
# Output:
0
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)

s_A = 0
s_B = 0
for i in range(N):
    if i % 2 == 0:
        s_A += a[i]
    elif i % 2 == 1:
        s_B += a[i]

print(s_A - s_B)

# Example run
# Input:
-18850
1484193033
# Output:
0
N = int(input())
A = [int(n) for n in input().split()]
a = 0
b = 0
for i in range(N):
  n = A.pop(A.index(max(A)))
  if (i % 2):
    b += n
  else:
    a += n
print(a-b)

# Example run
# Input:
-2090237817
-14
# Output:
0
N = int(input())
card_list = list(map(int,input().split()))
card_list.sort(reverse=True)
Alice_list = []
Bob_list = []

for i in range(N):
    if i%2 == 0:
        Alice_list.append(card_list[i])
    else:
        Bob_list.append(card_list[i])

print(sum(Alice_list)-sum(Bob_list))

# Example run
# Input:
-4868286
-104837
# Output:
0
N = int(input())
a = sorted(map(int, input().split()), reverse=True)

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


# Example run
# Input:
36702849
3185105
# Output:
3185105
n=int(input())
arr=list(map(int, input().split()))
a, b=0, 0
for k, v in enumerate(sorted(arr, reverse=True)):
  if k%2==0:
    a+=v
  else:
    b+=v
print(a-b)

# Example run
# Input:
-97071
36241
# Output:
36241
n = int(input())
As = list(map(int, input().split()))

Alics_score = 0
Bob_score = 0

for _ in range(int(n/2)+1):
    if As == []:
        break
    Alics_score += max(As)
    As.remove(max(As))
    if As == []:
        break
    Bob_score += max(As)
    As.remove(max(As))

print(Alics_score - Bob_score)

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

a.sort(reverse=True)

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

# Example run
# Input:
!d1,AYZU
220661337
# Output:
220661337
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])
    
if N%2 == 1:
    for y in range(1,N,2):
        B.append(a[y])
        
    
else:
    for y in range(1,N+1,2):
        B.append(a[y])
    
    
    

    

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


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

# Example run
# Input:
-247872467
-5363
# Output:
0
n = int(input())
a = sorted(map(int, input().split()), reverse=True)
alice = 0
bob = 0
for i, v in enumerate(a):
  if i & 1:
  	bob += v
  else:
    alice += v
 
print(alice - bob)
  

# Example run
# Input:
-114
-473
# Output:
-473
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:
-5271130
19
# Output:
19
num=int(input())
n=list(map(int,input().split()))
n.sort(reverse=True)
#print(n)
a=sum(n[::2])
b=sum(n[1::2])
print(a-b)

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

score.sort(reverse=True)
Alice = []
Bob = []
for i in range(len(score)):
  if i%2==0:
    Alice.append(score[i])
  else:
    Bob.append(score[i])
    
print(sum(Alice)-sum(Bob))


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

a.sort(reverse = True)

Ali = 0
Bob = 0

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

# Example run
# Input:
-83
-39355
# Output:
-39355
n = int(input())
a = sorted(list(map(int, input().split())),reverse = True)
Alice = 0
Bob = 0
count = 0

while True:
    Alice += a[count]
    count += 1
    if count == n:
        print(Alice - Bob)
        exit()
    Bob += a[count]
    count += 1
    if count == n:
        print(Alice - Bob)
        exit()

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

alice =[]
bob = []

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

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

a_sorted = sorted(a, reverse=True)

A_point = 0
B_point = 0

for i in range(0, N):
    if i%2 == 0:
        A_point += a_sorted[i]
    else:
        B_point += a_sorted[i]

print(A_point-B_point)

# Example run
# Input:
-29648058
-21
# Output:
0