Felix6326727/beyond-accuracy-code-comprehension huggingface dataset:
n = int(input())
a = list(map(int, input().split(" ")))
a.sort(reverse=True)
alice = 0
bob = 0
for i in range(0, n):
    if i % 2 == 0:
        alice += a[i]
    else: 
        bob += a[i]
print(int(alice - bob))

# Example run
# Input:
-436344399
-83
# Output:
0
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:
T~.yFv
4
# Output:
4
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse = True)
ans = 0
while len(A)>= 2:
  ans += A[0]-A[1]
  A = A[2:]
if len(A) == 1:
  ans += A[0]
print(ans)
  

# Example run
# Input:
14
-49093496
# Output:
-49093496
N=int(input())
C=list(map(int,input().split()))
D=sorted(C,reverse=True)
A=[]
B=[]
for (i,d) in enumerate(D):
    if i%2==0:
        A.append(d)
    else:
        B.append(d)
print(abs(sum(A)-sum(B)))
        
    

# Example run
# Input:
176397305
-2046600
# Output:
2046600
n = input()
lst = sorted([int(x) for x in input().split()], reverse=True)
alice = 0
bob = 0
for i in range(len(lst)):
    if i%2:
        bob += lst[I]
    else:
        alice += lst[i]
print(alice-bob)

# Example run
# Input:
@&1\)C[
144193987
# Output:
144193987
n = input()
sorted_cards = sorted(list(map(int, input().split())), reverse=True)
print(sum(sorted_cards[::2]) - sum(sorted_cards[1::2]))

# Example run
# Input:
&/AcoBtKm
2123709
# Output:
2123709
N = int(input())
ans_Alice = 0
ans_Bob = 0

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

a_new = sorted(a, reverse = True)


for i in range(0, N, 2):
	ans_Alice += a_new[i]
	
for j in range(1, N, 2):
	ans_Bob += a_new[j]


print(str(ans_Alice - ans_Bob))

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

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

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

# Example run
# Input:
0
805965556
# Output:
0
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:
-80
-7517
# 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:
-7038374
-6
# Output:
-6
n = input()
li = list(map(int,input().split()))
li.sort()
count = 1
Alice = 0
Bob = 0
for i in li:
    if count % 2:
        Alice += i
        count += 1
    else:
        Bob += i
        count += 1
print(Alice - Bob)

# Example run
# Input:
a:4}N
-4693
# Output:
-4693
N = int(input())
a_li = sorted(list(map(int,input().split())),reverse=True)
Alice = sum(a_li[::2])
Bob = sum(a_li) - Alice
print(Alice - Bob)


# Example run
# Input:
19801
1
# Output:
1
_ = input()
ls = list(map(int, input().split()))

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


# Example run
# Input:
HMzRw
-2540
# Output:
-2540
n = int(input())
lista = list(map(int, input().split()))

listb=sorted(lista, reverse=True)
print(listb)


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


print(alice-bob)


# Example run
# Input:
-1140
0
# Output:
[0]
0
N = int(input())
a = sorted(map(int,input().split()),reverse=True)
print(sum([a[i] * (-1)**i for i in range(N)]))


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

# Example run
# Input:
-1325982
57961
# Output:
57961
a = int(input())
b = [int(i) for i in (input().split())]
b.sort()
b.reverse()
sum = 0
for i in range(a):
    if i % 2 == 0:
        sum += b[i]
    else:
        sum -=b[i]
print(sum)


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

# Example run
# Input:
8029
-6
# Output:
-6
#!/usr/bin/env python
"""AtCoder Beginner Contest 088: B - Card Game for Two
https://atcoder.jp/contests/abc086/tasks/abc088_b
"""

__author__ = 'bugttle <bugttle@gmail.com>'


def main():
    N = int(input())
    an = list(map(int, input().split()))

    answer = 0
    an.sort(reverse=True)
    for i in range(N):
        if i % 2 == 0:
            answer += an[i]
        else:
            answer -= an[i]

    print(answer)


if __name__ == '__main__':
    main()


# Example run
# Input:
-18579092
21643
# Output:
0
N = int(input())
a = sorted(map(int, input().split()), 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:
0
-1378702
# Output:
0
input()
a=sorted(list(map(int,input().split())))
print(sum(a[::2])-sum(a[1::2]))

# Example run
# Input:
~u7vbT
115403
# Output:
115403
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:
4
-5
# Output:
-5
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:
0
8131
# Output:
8131
N = int(input())
list = sorted(list(map(int, input().split())),reverse=True)
print(sum(list[::2])- sum(list[1::2]))








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

# Example run
# Input:
Gih4AY`h
-58799
# Output:
-58799
n = int(input())
a = sorted(list(map(int, input().split())), reverse = True)

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

# Example run
# Input:
-11392175
-9
# Output:
0
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
A=sum(a[0::2])#リストの奇数項をとる
B=sum(a[1::2])
print(A-B)

# Example run
# Input:
-1
734377
# Output:
734377
n = int(input())
a = tuple(map(int,input().split()))
a = sorted(a)

alice = []
bob = []

if n%2 == 0:
  while(len(a)>0):
    alice.append(a.pop())
    bob.append(a.pop())
else:
  alice.append(a.pop())
  while(len(a)>0):
    bob.append(a.pop())
    alice.append(a.pop())
print(sum(alice)-sum(bob))


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

# Example run
# Input:
-2811762
15761764
# Output:
15761764
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
Alice = 0
Bob = 0
for i in range((n - 1) // 2 + 1):
    Alice = Alice + a[2 * i]
for i in range(n // 2):
    Bob = Bob + a[2 * i + 1]
gap = Alice - Bob
print(gap)

# Example run
# Input:
-33
-3724
# 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:
10
5330
# Output:
5330
N=int(input())
A=list(map(int,input().split()))
new_A=sorted(A,reverse=True)
alice_total=sum(new_A[0::2])
bob_total=sum(new_A[1::2])
print(alice_total-bob_total)

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

# Example run
# Input:
7
203880
# Output:
203880
def actual(N, A):
    A_desc = sorted(A, reverse=True)

    alice_cards = A_desc[::2]
    bob_cards = A_desc[1::2]

    return sum(alice_cards) - sum(bob_cards)

N = int(input())
A = map(int, input().split())

print(actual(N, A))

# Example run
# Input:
4
222770516
# Output:
222770516
N = int(input())
a = sorted([int(i) for i in input().split()], reverse=True)

Alice, Bob = 0, 0

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

print(Alice - Bob)

# Example run
# Input:
1911749
-124978655
# Output:
-124978655
N = int(input())
cards_number = input()
numbers = list(map(int, cards_number.split()))
ordered_numbers = sorted(numbers, reverse=True)

alice_cards = []
bob_cards = []
while len(ordered_numbers) != 0:
    try:
        alice_cards.append(ordered_numbers.pop(0))
        bob_cards.append(ordered_numbers.pop(0))
    except IndexError:
        break

alice_point = sum(alice_cards)
bob_point = sum(bob_cards)

print(alice_point-bob_point)


# Example run
# Input:
231768
9879
# Output:
9879
_ = input()
a,b = 0,0
cards = list(map(int, input().split()))
for i, c in enumerate(reversed(sorted(cards))):
  if i % 2 == 0:
    a += c
  else:
    b += c
print(a-b)

# Example run
# Input:
m~%@y;
253491
# Output:
253491
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:
186860433
108968
# Output:
[108968]
108968
def main():
    n = int(input())
    aa = sorted(map(int, input().split()), reverse=True)
    print(sum(aa[0::2]) - sum(aa[1::2]))


if __name__ == '__main__':
    main()


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

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

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

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

# Example run
# Input:
471
14
# Output:
14
n=int(input())
l=list(map(int,input().split()))
l.sort(reverse=True)
Alice=0
Bob=0

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

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

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

while True:
    if len(cards) == 0:
        break
    a += max(cards)
    cards.remove(max(cards))

    if len(cards) == 0:
        break
    b += max(cards)
    cards.remove(max(cards))

print(a - b)


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

A.sort(reverse=True)

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

print(alice - bob)


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

# Example run
# Input:
713362851
133233772
# Output:
133233772
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:
-153163
-32942311
# Output:
-32942311
N = int(input())
an = map(int, input().split())

san = sorted(an, reverse=True)
alice = 0
bob = 0
turn_alice = True
for a in san:
    if turn_alice:
        alice += a
    else:
        bob += a
    turn_alice = not turn_alice

print(alice - bob)


# Example run
# Input:
1
26
# Output:
26
N=int(input())
A=sorted(list(map(int,input().split())))
if N%2==0:
  a=0
  for i in range(int(N/2)):
    a+=A[2*i+1]-A[2*i]
else:
  a=A[0]
  for i in range(int(N/2)):
    a+=A[-(2*i+1)]-A[-(2*i+2)]
print(a)

# Example run
# Input:
-809459
3
# Output:
3
N = int(input())
a = []
a = input().split(' ')
a = [int(i) for i in a]
a = sorted(a, reverse=True)
Alice = 0
Bob = 0
for i in range(N):
  if i == 0:
    Alice += a[i]
  elif i%2 == 0:
    Alice += a[i]
  elif i%2 == 1:
    Bob += a[i]

print(Alice - Bob)

# Example run
# Input:
-1794
-1147387
# Output:
0
n = int(input())
a = [int(e) for e in input().split()]

a_desc = sorted(a, reverse=True)
ans = sum(a_desc[::2]) - sum(a_desc[1::2])
print(ans)


# Example run
# Input:
1
-3108573
# Output:
-3108573
def getInput():
    return [int(i) for i in input().rstrip().split(' ')]

N = getInput()[0];
a_i = getInput()
a_i.sort(reverse=True)
ret = 0

for i in range(1, N+1):
    if not i % 2 == 0:
        ret += a_i.pop(0)
    else:
        ret -= a_i.pop(0)
print(ret)

# Example run
# Input:
-2147483648
16667401
# Output:
0
n = int(input())
List = list(map(int,input().split()))
A = []
B = []
List = sorted(List,reverse=True)
for i in range(len(List)):
  if i%2 == 0:
    A.append(List[i])
  else:
    B.append(List[i])
Answer = sum(A) - sum(B)
print(Answer)

# Example run
# Input:
669
23
# Output:
23
N = int(input())
a = [int(aa) for aa in input().split()]
a.sort(reverse = True)
A = []
B = []
while len(a) > 0:
  A.append(a[0])
  a.pop(0)
  if len(a) == 0:
    break
  B.append(a[0])
  a.pop(0)
ans = sum(A) - sum(B)
print(ans)

# Example run
# Input:
1418198351
9
# Output:
9
n=int(input())
a=list(map(int,input().split()))
alice=0
bob=0
#降順ソート
a.sort()
a.reverse()

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

ans=alice-bob
print(ans)

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

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

# Example run
# Input:
-)5V,@
-997466
# Output:
-997466
N = input()
A = [int(hoge) for hoge in input().split()]
A.sort(reverse=True)
Alice = A[::2]
Bob = A[1::2]
print(sum(Alice)-sum(Bob))

# Example run
# Input:
U6qy)gAU
-15915
# Output:
-15915
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
Alice = list()
Bob = list()
print(a)
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:
-21
6534
# Output:
[6534]
0
# coding: utf-8

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

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

for i in range(0, N, 2):
    sum_a += a[i]
for i in range(1, N, 2):
    sum_b += a[i]

diff = sum_a - sum_b
print(diff)

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

one =[]
two =[]
count = 0
if N%2 ==0:
  while count <= N:
    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:
-29082932
-11385106
# Output:
0
N=int(input())
li=list(map(int,input().split()))

li_sorted=sorted(li, reverse=True)
sum=0
for i in range(N):
    if i%2==1:
        sum+=-1*li_sorted[i]
    else:
        sum+=li_sorted[i]
        
print(sum)

# Example run
# Input:
-151310
-18331
# Output:
0
N = int(input())
A = list(map(int,input().split()))
A.sort()
A.reverse()
cntA = 0
cntB = 0
flag = 0
for a in A:
    if flag == 0:
        cntA += a
        flag = 1
    else:
        cntB += a
        flag = 0
print(cntA-cntB)

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

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


# Example run
# Input:
-109089799
-74270783
# 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==1:
    S+=a[i]
  else:
    S-=a[i]
print(S)

# Example run
# Input:
-54266464
-274078593
# Output:
0
n = int(input())

a = sorted(list(map(int, input().split())), reverse=True)
ans = sum(a[::2]) - sum(a[1::2])
print(ans)

# Example run
# Input:
471
14
# Output:
14
N=int(input())
a=list(map(int,input().split()))

a.sort()
A=[]
B=[]
while(len(a)>0):
    A.append(a.pop())
    if len(a)==0: break
    B.append(a.pop())
print(sum(A)-sum(B))

# Example run
# Input:
0
227
# Output:
227
n = input()
a = list(map(int,input().split()))
alice = 0
bob = 0
while(a != []):
    alice += max(a)
    a.remove(max(a))
    if(a == []):
        break
    bob += max(a)
    a.remove(max(a))

print(alice-bob)

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

# Example run
# Input:
i|Fv
3294212
# Output:
3294212
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
Turn = True
Alice = 0
Bob = 0
for i in range(0, N):
    if Turn==True:
        Alice = Alice+a[i]
    else:
        Bob = Bob+a[i]
    Turn = not Turn
print("{}".format(Alice-Bob))


# Example run
# Input:
-9018239
1
# Output:
0
N = int(input())
a = list(map(int, input().split()))
a.sort()
A = 0
B = 0
for i in range(N):
  if i % 2 == 0:
    A += a[i]
  else:
    B += a[i]

print(abs(A-B))

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

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

# Example run
# Input:
-5363
1552
# Output:
1552
n = int(input())
a = [int(i) for i in input().split()]
A = []
B = []
if n % 2 == 0:
    while len(a) > 0:
        A.append(max(a))
        a.remove(max(a))
        B.append(max(a))
        a.remove(max(a))
else:
    while len(a) > 1:
        A.append(max(a))
        a.remove(max(a))
        B.append(max(a))
        a.remove(max(a))
    A.append(max(a))
print(sum(A) - sum(B))

# Example run
# Input:
-147
-3225
# Output:
-3225
n=int(input())
li=sorted(list(map(int,input().split())),reverse=True)
a=0
b=0

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

# Example run
# Input:
-135
67027107
# Output:
0
import math

N = input()
num_list = list(map(int,input().split(' ')))
i = 0
Bob = 0
Alice = 0
for n in sorted(num_list, reverse=True):
  i += 1
  if i % 2 == 1:
    Bob += n
  elif i % 2 == 0:
    Alice += n
ans = Bob - Alice
print(ans)

# Example run
# Input:
$oII~?i
-16
# Output:
-16
n = int(input())
L = list(map(int,input().split()))
L = sorted(L,reverse=True)
a,b = 0,0
for i in range(len(L)):
  if i%2 == 0:
    a += L[i]
  else:
    b += L[i]
print(a-b)

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

# Example run
# Input:
-1
719497470
# Output:
0
N=int(input())
S=list(map(int, input().split()))
S.sort(reverse=True)
A=[]
B=[]
for i in range(N):
    if i%2==0:
        A.append(S[i])
    else:
        B.append(S[i])
print(sum(A)-sum(B))


# Example run
# Input:
-16371
-52564348
# Output:
0
N=int(input())
l=list(map(int, input().split()))
C=0
l.sort()
l.reverse()
n=N//2
if N%2==1:
    C += min(l)
    l.remove(min(l))
for i in range(n):
    C += l[2*i]-l[2*i+1]
print(C)

# Example run
# Input:
-15303
-412794
# Output:
-412794
n = int(input())
a_list = [int(num) for num in list(input().split(" "))]

a_list.sort(reverse = True)

total_dif = 0
for a in range(0,n,2):
    if a+1 ==n:
        total_dif += a_list[a]
    else:
        total_dif += a_list[a]-a_list[a+1]
print(total_dif)


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


# Example run
# Input:
-1654029
-3
# Output:
0
import sys
def main():
    #s = sys.stdin.readlines()
    N = input() # number of card
    A = sorted(list(map(int,input().split())), reverse = True) # card
    Alice = sum([ a for i,a in enumerate(A) if i%2 == 0 ])
    Bob = sum([ a for i,a in enumerate(A) if i%2 == 1 ])
    print(Alice-Bob)

if __name__ == "__main__":
    main()

# Example run
# Input:
@`(RsV.z
0
# Output:
0
input()
a=list(map(int,input().split()))
a.sort(reverse=True)
print(sum([i for i in a[::2]])-sum([i for i in a[1::2]]))

# Example run
# Input:
~_p|DP\
-29588
# Output:
-29588
N = input()
A = list(input().split())
A = list(map(int,A))
A = sorted(A,reverse = True)
a = 0
b = 0
try :
  a += A.pop(0)
  b += A.pop(0)
except IndexError :
  print(a-b)
print(a-b)

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

# Example run
# Input:
-1014762
-1
# Output:
0
N = int(input())
a_line_map = map(int, input().split(' '))

sorted_a_map = sorted(a_line_map, reverse=True)
dif_gen = (-num if i%2==1 else num for i, num in enumerate(sorted_a_map))
print(sum(dif_gen))

# Example run
# Input:
-18762704
2147483647
# Output:
2147483647
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
print(sum(i for i in a[::2]) - sum(i for i in a[1::2]))

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

# Example run
# Input:
-5271130
19
# Output:
-19
n = int(input())
a = sorted(list(map(int, input().split())))
al = 0
bb = 0
for i in range(n):
  if i % 2 == 0:
    al += a[i]
  else:
    bb += a[i]
print(al - bb)

# Example run
# Input:
-87
141725276
# Output:
0
input()
card = [int(i) for i in input().split(" ")]
card.sort(reverse = True)

alice = [card[i] for i in range(len(card)) if i % 2 == 0]
bob = [card[i] for i in range(len(card)) if i % 2 == 1]

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

# Example run
# Input:
<7;cq=r
-2
# Output:
-2
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9

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

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


if __name__ == '__main__':
    main()


# Example run
# Input:
18673
158
# Output:
158
#!/usr/bin/env python3
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
ans = sum(a[::2]) - sum(a[1::2])
print(ans)


# Example run
# Input:
-316
-160045822
# Output:
-160045822
N=int(input())
A=sorted(list(map(int,input().split())))[::-1]
B=[A[i] for i in range(len(A)) if i %2 == 0 ] #Alice
C=[A[i] for i in range(len(A)) if i %2 != 0 ] #Bob

print(sum(B)-sum(C))


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

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

point_Alice = 0
point_Bob = 0

b = sorted(a,reverse=True)

while True:
    point_Alice += b.pop(0)
    if b == []:
        break
    point_Bob += b.pop(0)
    if b == []:
        break

ans = point_Alice - point_Bob
print(ans)


# Example run
# Input:
479
-21519471
# Output:
-21519471
N = int(input())
A = [int(i) for i in input().split()]

As = sorted(A,reverse = True)
count = 0
for i in range(N):
  if i % 2 == 0:
    count += As[i]
  else:
    count -= As[i]
print(count)

# Example run
# Input:
-133790981
215616622
# Output:
0
# -*- coding: utf-8 -*-
     
input_lines=input()
 
input_lines=input()

tmp_lst1=input_lines.split()
tmp_lst2=list(map(int,tmp_lst1))
tmp_lst2.sort()
tmp_lst2.reverse()
#print(tmp_lst2)

alice=0
bob=0
for i in tmp_lst2:
    if tmp_lst2.index(i)%2==0:
        alice=alice+i
    else:
        bob=bob+i

sub=alice-bob
print(sub)


# Example run
# Input:
zI?$P]'G3
182
# Output:
182
n=int(input())
a=sorted([int(_) for _ in input().split()], key=lambda x: -x)
print(sum(a[::2])-sum(a[1::2]))

# Example run
# Input:
186251406
-133790981
# Output:
-133790981
n = int(input())
a = int(input())

ans = 'No'
for i in range(a+1):
    if (n-i)%500 == 0:
        ans = 'Yes'
        break
print(ans)


# Example run
# Input:
1
-68037
# Output:
No
N = int(input())
m = [int(i) for i in input().split()]
m.sort(reverse=True)
ans = 0
for a in range(0, N, 2):
    ans += m[a]
for a in range(1, N, 2):
    ans = ans - m[a]

print(ans)
    



# Example run
# Input:
-1
30456987
# Output:
0