Felix6326727/beyond-accuracy-code-comprehension huggingface dataset:
def game(a, n):
    cards = sorted(a, reverse=True)
    alice = [cards[i] for i in range(n) if i % 2 == 0]
    bob = [cards[i] for i in range(n) if i % 2 != 0]
    return sum(alice) - sum(bob)


if __name__ == '__main__':
    n = int(input())
    a = map(int, input().split())
    print(game(a, n))


# Example run
# Input:
-5363
1552
# Output:
0
n = input()
a = [int(x) for x in input().split()]
print(sum(a[::2]) - sum(a[1::2]))


# Example run
# Input:
uxOg\
-20720
# Output:
-20720
a=int(input())
b=[int(i) for i in input().split()]
c=sorted(b)
#print(c)
d=sum(c[0::2])
e=sum(c[1::2])
print(e-d)


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

print(sum)


# Example run
# Input:
-331748
14563732
# Output:
0
n = int(input())
alist = list(map(int, input().split()))
alist.sort(reverse=True)
p1 = []
p2 = []
for i in range(n):
    if i%2 == 0:
        p1.append(alist.pop(0))
    else:
        p2.append(alist.pop(0))

print(sum(p1)-sum(p2))

# Example run
# Input:
-2811762
15761764
# Output:
0
N=int(input())

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

a.sort(reverse=True)
A=[]
B=[]

for i,k in enumerate(a):
    if i%2 == 0:
        A.append(a[i])
               
               
    elif i%2 == 1:
        B.append(a[i])
        
    
print(sum(A)-sum(B))    

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


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

a.sort()
a.reverse()

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

print(alice - bob)

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

# Example run
# Input:
=C>#:pjLk
38379
# Output:
38379
N = int(input())
a = list(map(int, input().split()))
Alice = 0
Bob = 0
a.sort()
a.reverse()
for i in range(N):
	if i % 2 == 0:
		Alice += a[i]
	else:
		Bob += a[i]
print(Alice - Bob)

# Example run
# Input:
-740
1
# Output:
0
n = int(input())
a = list(map(int, input().split()))
a.sort()
a.reverse()
# slice操作 --> [start:stop:step]
# 奇数番目の要素の和 - 偶数番目の要素の和
print(sum(a[::2]) - sum(a[1::2]))

# Example run
# Input:
1
13
# Output:
13
N = int(input())
ary = list(map(int, input().split()))

ary = sorted(ary, reverse=True)
scores = [0, 0]
turn = 0
while len(ary) > 0:
    s = ary.pop(0)
    scores[turn] += s
    turn = (turn + 1) % 2

diff = scores[0] - scores[1]
print(diff)


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

# Example run
# Input:
g>xkU
-316
# Output:
-316
N = int(input())
a = list(map(int, input().split()))

def sort_reverse(n):
    n.sort(reverse=True)
    return n

N_Even = list(range(0, N+1, 2))
N_Odd = list(range(1, N+1, 2))
a1 = sort_reverse(a)
sum1 = 0
sum2 = 0

for i in N_Even:
    sum1 += a1[i]
for j in N_Odd:
    sum2 += a1[j]

print(sum1 - sum2)

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

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


# Example run
# Input:
-21000
3
# Output:
3
N = int(input())
a_n =list(map(int,input().split()))
a_n=sorted(a_n)

result = 0
while len(a_n)>0:
    result +=a_n.pop()
    if len(a_n)>0:
        result  -=a_n.pop()
print(result)

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

# Example run
# Input:
-47187920
-8116
# Output:
0
input()
a = sorted(list(map(int, input().split())), reverse=True)
print((sum([i for i in a[0::2]]) - sum([i for i in a[1::2]])))


# Example run
# Input:
d-3D,
1611931113
# Output:
1611931113
N = int(input())
A = list(map(int, input().split()))

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

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

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

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

print(a-b)


# Example run
# Input:
-97075663
1
# Output:
1
n = int(input())
arr = list(map(int, input().split(" ")))

# Sort arr, firstly
arr.sort(reverse=True)

a_arr = []
b_arr = []

for (i, ele) in enumerate(arr):
    # Alice
    if i % 2 == 0:
        a_arr.append(ele)
    # Bob
    else:
        b_arr.append(ele)

print(sum(a_arr) - sum(b_arr))

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

# Example run
# Input:
-84521052
-2
# Output:
0
def main():
    N = int(input() )
    a = []
    a = [int(num) for num in input().split() ]
    
    a.sort(reverse = True )
#    print(a)
#    print(a[0::2 ] )
#    print(a[1::2 ] )
    
    score_A = sum(a[0::2 ] )
    score_B = sum(a[1::2 ] )
    
    print(score_A - score_B)
    
if __name__=="__main__":
    main()

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

Alice_score = 0
Bob_score = 0
for i in range(-(-N//2)): # 回数
    Alice_score += max(a)
    a.remove(max(a))
    if len(a) == 0: 
        break
    Bob_score += max(a)
    a.remove(max(a))
print(Alice_score - Bob_score)

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

while l:
  m1 = max(l)
  a += m1
  l.remove(m1)
  if l:
    m2 = max(l)
    l.remove(m2)
print( 2 * a - s )



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

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

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

# Example run
# Input:
f*R:
473300
# Output:
473300
n = int(input())
a = list(map(int, input().split()))

b = sorted(a, reverse=True)

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

# Example run
# Input:
-696
-2978029
# Output:
0
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# Set 2 dimension list
def dim2input(N):
    li = []
    for _ in range(N):
        li.append(list(map(int, input())))
    return li

""" input template
S = input()
N = int(input())
L = list(map(int, input().split()))
a, b = list(map(int, input().split()))
SL = list(input())
"""

# --------------------------------------------

dp = None

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

    Alice = 0
    Bob = 0

    while len(A) != 0:
        Alice += max(A)
        A.remove(max(A))

        if len(A) == 0:
            break

        Bob += max(A)
        A.remove(max(A))

    print(Alice - Bob)

main()


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

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

# Example run
# Input:
-172829
-227062494
# Output:
-227062494
alice = 0
bob = 0
ignore= input()
cards = []
cards.extend(map(int,input().split()))
for i in sorted(cards,reverse=True)[0::2]:
    alice += i
for i in sorted(cards,reverse=True)[1::2]:
    bob += i
print(alice-bob)

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

# Example run
# Input:
-9179099
165350
# Output:
165350
N = int(input())
A = input().split(" ")
A = [int(i) for i in A]
A = sorted(A,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:
-16
5215966
# Output:
0
N = int(input())
numbers = list(map(int,input().split()))
numbers.sort(reverse=True)
Bob = 0
Alice = 0
for i,number in enumerate(numbers):
  if i == 0:
    Alice += number
  elif i%2 == 0:
    Alice += number
  else:
    Bob += number
ans = Alice - Bob
print(ans)

# Example run
# Input:
-123410341
9062461
# Output:
9062461
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:
-1
-3439167
# Output:
-3439167
N = int(input())
A = list(map(int,input().split(" ")))
A = sorted(A,reverse=True)
a_sum = 0
b_sum = 0
for i in range(len(A)):
    if i%2==0:
        a_sum+= A[i]
    else:
        b_sum += A[i]

print(a_sum-b_sum)

# Example run
# Input:
155287
-746
# Output:
-746
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
s=0
d=0
for i in range(len(a)):
  if i%2==0:
    s+=a[i]
  else:
    d+=a[i]

print(s-d)

# Example run
# Input:
450137
-9486
# Output:
-9486
import math

#n, a, b= map(int, input().split())
#a, b  = map(int, input().split())
#h = list(map(int, input().split()))
#s = list(str(input()))
n = int(input())
a = list(map(int, input().split()))

alice = 0
bob   = 0

for i in range(n):
  a.sort(reverse=True)
  alice = alice + a[0]*((i+1)%2)
  bob   = bob   + a[0]*(i%2)
  a[0] = 0
    
print(alice - bob)

# Example run
# Input:
-1131247330
-9
# Output:
0
N = int(input())
a = [int(k) for k in input().split()]
a.sort(reverse = True)
sub = 0

for i in range(N//2):
    sub += a[2*i] - a[2*i +1]
if (N%2 == 1):
    sub += a[-1]

print(sub)


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

n_list.sort(reverse=True)

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

# Example run
# Input:
_"A[P)
-2147483648
# Output:
-2147483648
n = list(map(int , input().split()))
a = list(map(int , input().split()))

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

# Example run
# Input:
-155785153
-104837
# Output:
[-104837]
-104837
N=int(input())
n=[int(i) for i in input().split()]
list.sort(n,reverse=True)
Ali=0
Bob=0

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

# Example run
# Input:
-58867430
-56661351
# 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]

diff = Alice - Bob
print(diff)

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

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


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

A = sorted(A, reverse=True)

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

print(alice - bob)

# Example run
# Input:
22
-133790981
# Output:
-133790981
n=int(input())
a=list(map(int,input().split()))
a=sorted(a)

alice=0
bob=0
i=0
while a:
    if i%2==0:
        alice+=a.pop()
    else:
        bob+=a.pop()
    i+=1
print(alice-bob)

# Example run
# Input:
0
13
# Output:
13
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

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

print(a-b)

# Example run
# Input:
1
-3108573
# Output:
-3108573
n = int(input())
x = input()
a = sorted([int(i) for i in x.split()])[::-1]
alice = sum([i for n,i in enumerate(a) if n%2==0])
bob = sum([i for n,i in enumerate(a) if n%2!=0])
print(alice-bob)

# Example run
# Input:
380581
8
# Output:
8
#!/usr/bin/env python3


def main():
    n = int(input())
    l = list(map(int, input().split()))
    l.sort(reverse=True)

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

if __name__ == '__main__':
    main()

# Example run
# Input:
36241
52108041
# Output:
52108041
N = int(input())
cards = sorted(list(map(int, input().split())), reverse=True)

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:
0
605260
# Output:
0
n = int(input())
m = list(map(int, input().split()))
m.sort(reverse=True)
a = 0
b = 0
t = True
for i in m:
  if t:
    a += i
  else:
    b += i
  t = True if not(t) else False
print(a-b)

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

alice = 0
bob = 0

for i in range(0, len(A), 2):
    alice += A[i]
    if len(A) > i + 1:
        bob += A[i + 1]

print(alice - bob)

# Example run
# Input:
AuyGE(ah
-2503
# Output:
-2503
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:
-309755155
0
# Output:
0
if __name__ == '__main__':
    n = int(input())
    cardlist = list(map(int, input().split()))
    cardlist.sort()

    alice_s, bob_s = 0, 0
    while cardlist != []:
        alice_s += cardlist.pop()
        if cardlist == []:
            break
        bob_s += cardlist.pop()
    ans = alice_s - bob_s
    print(ans)


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

# Example run
# Input:
33729406
142
# Output:
142
n = int(input())
a_list = [int(i) for i in input().split()]
a_list.sort(reverse=True)
alice = sum(a_list[0::2])
bob = sum(a_list[1::2])
print(alice-bob)

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

# Example run
# Input:
-439
20405993
# Output:
20405993
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:
204095531
1
# Output:
1
# -*- 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:
1
-124978655
# Output:
-124978655
#!/usr/bin/env python3


def main():
    N = int(input())
    aList = list(map(lambda x: int(x), input().split()))

    aliceValue = 0
    bobValue = 0
    isAliceTurn = True
    while len(aList) > 0:
        maxValue = max(aList)
        aList.remove(maxValue)
        if isAliceTurn:
            aliceValue += maxValue
        else:
            bobValue += maxValue

        isAliceTurn = not isAliceTurn

    print(aliceValue - bobValue)


if __name__ == "__main__":
    main()


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

# Example run
# Input:
-11989124
-407
# Output:
0
def main():
    N = int(input())
    A = map(int, input().split())

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

    ans = alice - bob
    print(ans)


if __name__ == '__main__':
    main()


# Example run
# Input:
-61684020
84816755
# Output:
84816755
N = int(input())
li = list(map(int,input().split()))
li.sort()
li = li[::-1]

Alice = li[0::2]
Bob = li[1::2]

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

# Example run
# Input:
67146844
-507122
# Output:
-507122
N = int(input())
As = map(int, input().split())
sorted_As = sorted(As, reverse=True)
alice_sum = 0
bob_sum = 0
for i, a in enumerate(sorted_As):
    if (i+1) % 2 == 1:
        alice_sum += a
    else:
        bob_sum += a
print(alice_sum - bob_sum)

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

# Example run
# Input:
3646
-14968
# Output:
-14968
N = int(input())
a_list = list(map(int,input().split()))

a_list.sort(reverse=True)
Asum = 0
Bsum = 0

for i in range(0,N,2):
    Asum += a_list[i]

for i in range(1,N,2):
    Bsum += a_list[i]

print(Asum-Bsum)


# Example run
# Input:
-2147483648
450137
# Output:
0
_ = int(input())
cards = sorted(map(int, input().split()), reverse=True)

res = 0
for i in range(len(cards)):
    if i % 2 == 0:
        res += cards[i]
    else:
        res -= cards[i]

print(res)

# Example run
# Input:
-15303
-412794
# Output:
-412794
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(f-e)

# Example run
# Input:
86342186
37777
# Output:
-37777
n = int(input())
a = input().split()

a = list(map(int, a))
a.sort(reverse=True)
alice_n = a[::2]
bob_n = a[1::2]

print(sum(alice_n) - sum(bob_n))

# Example run
# Input:
1992547
-30127045
# Output:
-30127045
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
total=sum(a)
alice_cnt=0
for i in range(0,n,2):
    alice_cnt+=a[i]
bob_cnt=total-alice_cnt
print(alice_cnt-bob_cnt)

# Example run
# Input:
-89579
-64
# Output:
64
def card_game():
    n = int(input())
    a_li = [int(i) for i in input().split()]
    ans = 0
    turn_switch = True

    li = sorted(a_li, reverse=True)

    for i in li:
        if turn_switch:
            ans += i
            turn_switch = False
        else:
            ans -= i
            turn_switch = True

    return ans


if __name__ == '__main__':
    print(card_game())


# Example run
# Input:
-2540
-1836
# Output:
-1836
n = int(input())
a = [int(i) for i in input().split(" ")]

a.sort()
m = n % 2

alice = 0
bob = 0

while n > 0:
    if n % 2 == m:
        alice += a[-1]
    else:
        bob += a[-1]
    a.pop()
    n -= 1

print(alice - bob)

# Example run
# Input:
-15913
-3391654
# Output:
0
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    n = int(input())
    a = sorted([int(i) for i in input().split()], reverse=True)

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

    print(alice - bob)


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

# Example run
# Input:
-2503
10842
# Output:
10842
input()
a = list(map(int, input().split()))
a.sort()
print(sum(a[::-2]) - (sum(a) - sum(a[::-2])))



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

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

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

# Example run
# Input:
637975
-21
# Output:
-21
N=int(input())
a=sorted(map(int,input().split()),reverse=True)
ans=sum(((-1)**i)*x for i,x in enumerate(a))
print(ans)

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

a.sort()

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

print(ret)

# Example run
# Input:
-2147483648
33729406
# 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:
-97
-55243509
# Output:
-55243509
n = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)

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


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

# Example run
# Input:
4G9
-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:
104773
-8
# Output:
-8
n = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)

Alice = sum(A[0::2])
Bob = sum(A)-Alice

print(Alice-Bob)

# Example run
# Input:
-516
148298
# Output:
148298
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:
-3753932
42339391
# Output:
0
n=int(input())
a=list(map(int,input().split()))
a=sorted(a, reverse=True)
scorea=0
scoreb=0
for i in range(n):
    if i%2==0:
        scorea+=a[i]
    else:
        scoreb+=a[i]

print(scorea-scoreb)

# Example run
# Input:
-579377
-21
# Output:
0
n = int(input())
an = list(map(int, input().split()))

an = sorted(an, reverse=True)
alice = sum([an[i] for i in range(len(an)) if i % 2 == 0])
bob = sum([an[i] for i in range(len(an)) if i % 2 == 1])
print(alice - bob)

# Example run
# Input:
-11392175
-9
# Output:
-9
N = int(input())
a = list(map(int, input().split()))
A, B = 0, 0
a.sort()
a.reverse()

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

print(A - B)


# Example run
# Input:
-171
158214411
# Output:
0
n=int(input())
a=[int(i) for i in input().split()]
a.sort(reverse=True)
b=0
c=0
if n%2==0:
    for i in range(n//2):
        b+=a[2*i]
        c+=a[2*i+1]
else:
    for i in range(n//2):
        b+=a[2*i]
        c+=a[2*i+1]
    b+=a[n-1]
if b>c:
    print(b-c)
else:
    print(c-a)


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


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


# Example run
# Input:
84
-694262
# Output:
-694262
n = int(input())
numArray = list(map(int,input().split()))

numArraySorted = sorted(numArray,reverse=True) #soted method cannot change raw data

alice = 0
bob = 0

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

print(alice-bob)



# Example run
# Input:
25627025
-53605951
# Output:
-53605951
n=int(input())
lst=list(map(int,input().split()))
al=0
bo=0
while True:
    m=max(lst)
    al+=m
    lst.remove(m)
    if len(lst)==0:
        break
    m=max(lst)
    bo+=m
    lst.remove(m)
    if len(lst)==0:
        break
print(al-bo)



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

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

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

# Example run
# Input:
7kURZXqH
1307
# Output:
1307