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(len(a)):
    if i % 2 == 0:
        alice += a[i]
    else:
        bob += a[i]
ans = alice - bob
print(ans)

# Example run
# Input:
119
-14
# Output:
-14
n = int(input())
a = input()

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

alice = []
bob = []
for na in range(int(n)):
    if na == 0 or na % 2 == 0:
        maxn = max(nums)
        alice.append(maxn)
        nums.remove(maxn)
    else:
        maxn = max(nums)
        bob.append(maxn)
        nums.remove(maxn)

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


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

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

# Example run
# Input:
-80
-7517
# Output:
-7517
N=int(input())
A=list(map(int, input().split()))
A.sort(reverse=True)
Alice=[]
Bob=[]
for i in range(len(A)):
  if i%2==0:
    Alice.append(A[i])
  else:
    Bob.append(A[i])

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

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

def puts(s): # 個人的にこのほうが解りやすいので。。。
    print(s)

def puti(i): # put integer
    print(str(i))

A.sort(reverse=True)

alice = 0
bob = 0

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

puti(alice - bob)


# Example run
# Input:
1
4887419
# Output:
4887419
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:
0
-83
# Output:
-83
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:
-1
-5
# Output:
-5
N=int(input())
ls=sorted([int(s) for s in input().split()],reverse=True)
print(sum([ls[i]*((-1)**i) for i in range(N)]))

# Example run
# Input:
-318594
-13
# Output:
0
def main():
    N = int(input())
    a = list(map(lambda i: int(i), input().split()))
    a.sort()
    alice = []
    bob = []
    for i in range(len(a)):
        if i % 2 == 0:
            alice.append(a[len(a) - 1 - i])
        else:
            bob.append(a[len(a) - 1 - i])
    print(sum(alice) - sum(bob))

main()


# Example run
# Input:
-48
465
# Output:
465
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:
9
896
# Output:
896
def main():
    target_num = input()
    target_list = list(map(int, input().split()))

    target_list.sort(reverse=True)

    result_a = 0
    result_b = 0
    a_flg = True
    for target in target_list:
        if a_flg:
            result_a += int(target)
            a_flg = False
        else:
            result_b += int(target)
            a_flg = True

    print(result_a - result_b)


if __name__ == '__main__':
    main()


# Example run
# Input:
:7D\[mf
2147483647
# Output:
2147483647
N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
x=0
y=0
for i,a in enumerate(A):
    if i%2==0:
        x+=a
    else:
        y+=a
print(x-y)

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


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

# a[i]を降順にソート
a.sort(reverse=True)

# A_total = Aliceの点数、B_total = Bobの点数
A_total = 0
B_total = 0

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

print(A_total - B_total)


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

ys = reversed(sorted(xs))
answer = 0
for i, y in enumerate(ys):
    if i % 2 == 0:
        answer = answer + y
    else:
        answer = answer - y
print(answer)

# Example run
# Input:
u~[=d
-11157473
# Output:
-11157473
N = int(input())
a =[int(i) for i in input().split()]
a.sort()
a.reverse()
x = a[::2] 
y = a[1::2]
print(sum(x)-sum(y))

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

# Example run
# Input:
F\dkG
37777
# Output:
37777
import math
N = int(input())
M = list(map(int, input().split()))
alice = 0
bob = 0
M.sort()
for i in range(math.ceil(N/2)): 
    alice += M[2*i]
    if N % 2 != 0 and i == int(N/2):
        break
    bob += M[2*i+1]
print(abs(alice - bob))

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

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

# Example run
# Input:
#Wur-J
0
# Output:
0
n=int(input())
a=[int(x) for x in input().split()]
a.sort(reverse=True)
alice=0
bob=0
for i in range(0,n,2):
  alice+=a[i]
for i in range(1,n,2):
  bob+=a[i]
print(alice-bob)

# Example run
# Input:
0
-17760757
# Output:
0
n = int(input())
a = list(map(int, input().split()))
a1 = sorted(a)
sum_a = 0
sum_b = 0

for i in range(n):
    if(n%2==0):
        if(i%2 != 0):
            sum_a += a1[i]
        else:
            sum_b += a1[i]
    else:
        if(i%2 == 0):
            sum_a += a1[i]
        else:
            sum_b += a1[i]
print(sum_a-sum_b)

# Example run
# Input:
-14993
-377
# Output:
0
n = int(input())

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

card.sort(reverse = True)

a = 0

b = 0

turn  = 0

for i in card:
    if turn == 0:
        a += i
        turn = 1
    else:
        b += i
        turn = 0
        
print(a-b)

# Example run
# Input:
-86
11
# Output:
11
n=int(input())
a = [int(i) for i in input().split()] 
A=0
B=0
C=0
k=0
for i in range(n):
  if i%2==0:
    k=max(a)
    A += k
    del a[a.index(k)]
  else :
    k=max(a)      
    B += k
    del a[a.index(k)]   
  
C=A-B          
print(C)          

# Example run
# Input:
-90312
-12211339
# Output:
0
N=int(input())
ls=list(map(int,input().split()))
lst=sorted(ls,reverse=True)

A=[]
B=[]

for i in range(N):
    if i==0 or i%2==0:
        A.append(lst[i])
    else:
        B.append(lst[i])

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

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

# Example run
# Input:
ZMI.`,cSh
-15603675
# Output:
-15603675
# B - Card Game for Two
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
ans = 0
for i in range(N):
    ans = ans+A[i] if i%2==0 else ans-A[i]
print(ans)

# Example run
# Input:
-3550
-11385106
# Output:
0
N=int(input())
cards=sorted(list(map(int,input().split())))[::-1]
A=sum(cards[::2])
B=sum(cards[1::2])
print(A-B)

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

# Example run
# Input:
-151346
-519373
# Output:
-519373
n = int(input())
a = list(map(int,input().split()))
A = sorted(a,reverse=True)
alice = []
bob = []
if n%2==0:
    for i in range(n//2):
        alice.append(A[0])
        A.pop(0)
        bob.append(A[0])
        A.pop(0)
    print(sum(alice)-sum(bob))
else:
    for i in range(n//2):
        alice.append(A[0])
        A.pop(0)
        bob.append(A[0])
        A.pop(0)
    alice.append(A[0])
    print(sum(alice)-sum(bob))

# Example run
# Input:
-14
0
# Output:
0
input()
*A,=reversed(sorted(map(int,input().split())))
a=sum(A[0::2])
print(2*a-sum(A))


# Example run
# Input:
J\S}6A
-848
# Output:
-848
N=int(input())
a_list=list(map(int,input().split()))
a_list.sort(reverse=True)
Asum=0
Bsum=0
for i in range(N):
    if i%2==0:
        Asum+=a_list[i]
    else:
        Bsum+=a_list[i]
print(Asum-Bsum)

# Example run
# Input:
-887384
13499019
# 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:
1
-227348
# Output:
-227348
N = int(input())
a = list(map(int, input().split()))

a.sort(reverse=True)
#print(a)
ans=0
for i in range(N):
    if i % 2 ==0:
        ans += a[i]
    else:
        ans -= a[i]
print(ans)

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

print(abs(a-b))


# Example run
# Input:
3185105
629110165
# Output:
[629110165]
629110165
N = int(input())
a = [int(c) for c in input().split()]
alice = 0
bob = 0

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

print(alice - bob)

# Example run
# Input:
-523929617
-147
# Output:
-147
import math
def main():
  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)
main()


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

# Example run
# Input:
1332
-2239572
# Output:
2239572
N = int(input())


a = list( sorted(map( int, input().split())))[::-1]

A_B = 0
B = 1

for i in a:
	A_B += i * B 
	B *= -1
    
print(A_B)


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

a.sort()
a.reverse()

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

print(total)


# Example run
# Input:
-23909
-68
# Output:
0
n = int(input())
a = sorted(list(map(int,input().split())),reverse=True)
alice = 0
bob = 0

while True:
  alice += a[0]
  del a[0]
  if a == []:
    break
  bob += a[0]
  del a[0]
  if a == []:
    break

print(alice - bob)

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

A = sorted(A,reverse = True)

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

# Example run
# Input:
197766
-101281970
# Output:
-101281970
n = int(input())
lis = [int(i) for i in input().split()]
alice = 0
bob =0


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

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

a.sort()
a.reverse()

A = a[::2]
B = a[1::2]

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

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

Alice_score=0
Bob_score=0

isAliceTurn=True
for i in range(N):
    if(isAliceTurn):
        Alice_score+=cards.pop(0)
    else:
        Bob_score+=cards.pop(0)
    isAliceTurn = not isAliceTurn

print(Alice_score-Bob_score)

# Example run
# Input:
-37
1
# Output:
0
## ABC 088
n = int(input())
cl = [int(_) for _ in input().split()]

cl.sort(reverse=True)

alice = 0
bob = 0

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

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


# Example run
# Input:
-1504387
31
# Output:
0
#ABC 088 B
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
Alice=0
Bob=0

if len(A)%2==1:
    A.append(0)

while len(A)>=1:
    Alice+=A.pop(0)
    Bob+=A.pop(0)
print(Alice-Bob)

# Example run
# Input:
0
605260
# Output:
605260
n = input()
cards = list(map(int, input().split()))
cards.sort(reverse = True)

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

print(alice-bob)

# Example run
# Input:
F\dkG
37777
# Output:
37777
def resolve():
    N = int(input())
    A = list(reversed(sorted([int(i) for i in input().split(maxsplit=N)])))
    print(sum(A[0::2]) - sum(A[1::2]))


resolve()


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

a.sort(reverse=True)

alice = 0
bob = 0

for i,j in enumerate(a):
    if i % 2 == 0:
        alice += j
    else:
        bob += j

print(alice - bob)


# Example run
# Input:
],UXA
-109749
# Output:
-109749
# -*- coding: utf-8 -*-
#input number
num = int(input())
str = input()
#change to list distinguished by space
str_list = str.split()
#change list all item to "int"
list_up = list( map((lambda x:int(x)),str_list))

#arrange number from high number to low number
list_up.sort(reverse=True)
sum = 0
for (i, v) in enumerate(list_up):
  if(i % 2 == 0):
    sum += int(v)
  elif(i % 2 == 1):
    sum -= int(v)
print(sum)

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

Alice = sum(a[0::2])
Bob = sum(a[1::2])

print(Alice-Bob)


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

a.sort(reverse=True)

x=0
p_alice=0
p_bob=0

while (x < n):
    if(x%2==0):
        p_alice += a[x]
    else:
        p_bob += a[x]
    x+=1

print(p_alice-p_bob)

# Example run
# Input:
-233
-48
# Output:
0
n = int(input())
a_list = list(map(int, input().split()))
alice = 0
bob = 0

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

# Example run
# Input:
-728818981
-2811762
# Output:
0
n=int(input())
A=list(map(int,input().split()))
A.sort()
total=0
i=n-1
while(0<=i-1):
  total+=A[i]-A[i-1]
  i-=2
if(i==0):
  total+=A[0]
print(total)

# Example run
# Input:
-124978655
-23909
# Output:
0
# https://atcoder.jp/contests/abc088/tasks/abc088_b
n = int(input())
a = [int(x) for x in input().split()]
alice = 0
bob = 0
for i, v in enumerate(sorted(a, reverse=True)):
    if (i % 2 == 0):
        alice += v
    else:
        bob += v
print(alice - bob)


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


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

alice = 0
bob = 0
c = 0
while len(a) > 0:
    m = max(a)
    i = a.index(m)
    a.pop(i)
    if c % 2 == 0:
        alice += m
    else:
        bob += m
    c += 1

print(alice - bob)


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

alice_list = a_sorted[::2]
bob_list = a_sorted[1::2]

print(sum(alice_list) - sum(bob_list))

# Example run
# Input:
YQoc
11609
# Output:
11609
n=int(input())
a=list(map(int,input().split()))
d=0
a.sort()
a.reverse()
for i in range(0,n,2):
 d+=a[i]
arisu=d
bobu=sum(a)-d

print(arisu-bobu)


# Example run
# Input:
-18229
-16112
# Output:
16112
n=int(input())
l=list(map(int,input().split()))
l.sort(reverse=True)
alice=sum(l[::2])
Bob=sum(l[1::2])

ans=alice-Bob

print(ans)

# Example run
# Input:
2920762
-6
# Output:
-6
N = int(input())
 
if N%2 == 0:
  print(N/2)
else:
  print(N+1 / 2)

# Example run
# Input:
-7930
# Output:
-3965.0
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:
2116
-579377
# Output:
-579377
n=int(input())
a=[int(i) for i in input().split()]
list.sort(a,reverse=True)
print(sum(a[::2])-sum(a[1::2]))

# Example run
# Input:
815
12824734
# Output:
12824734
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
print(sum(a[0::2])*2-sum(a))

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

# Example run
# Input:
-740
1
# Output:
1
n = int(input().rstrip())
a = map(int,input().rstrip().split())
b = list(sorted(a,reverse=True))

c = 0
ad = 0
for i in range(n):
 if c == 0:
  ad += b[i]
  c = 1
 else:
  ad -= b[i]
  c = 0

print(ad)
 


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

# Example run
# Input:
10366
-5271130
# Output:
-5271130
N = int(input())
num_list = list(map(int, input().split()))

num_list = sorted(num_list)

point = 0
player = 1
while num_list:
    point += num_list.pop() * player
    player *= -1

print(point)

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


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

# Example run
# Input:
5<aR[-+
-559990065
# Output:
-559990065
# coding: utf-8
N = int(input())
a = list(map(int, input().split()))

a.sort()
a.reverse()

alice = 0
bob = 0
for i, v in enumerate(a):
    if i % 2 == 0:
        alice += v
    else:
        bob += v

print(alice-bob)


# Example run
# Input:
-1
-3439167
# Output:
-3439167
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
sum1 = 0
sum2 = 0
for j in range(N):
    if j%2 == 0:
        sum1 = sum1 + a[j]
    elif j%2 ==1:
        sum2 = sum2 + a[j]
print(sum1 - sum2)


# Example run
# Input:
-1
-3439167
# Output:
0
n = int(input())
a = [int(x) for x in input().split()]
sortA = sorted(a, reverse=True)
Alice = 0
Bob = 0
print(sortA)
for i in range(len(a)):
    if i % 2 == 0:
        Alice+=sortA[i]
    else:
        Bob+=sortA[i]
    
print(Alice - Bob)

# Example run
# Input:
386945
3485
# Output:
[3485]
3485
N = int(input())
a = list(int(i) for i in input().split()) 

a.sort(reverse = True) ##sortとreveseの一括操作

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:
-622
-517326
# Output:
0
N = int(input())
A =list(map(int, input().split()))

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

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


# Example run
# Input:
20794
14319043
# Output:
14319043
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:
-11329
-25867257
# Output:
0
def resolve():
    '''
    code here
    '''
    N = int(input())
    As = [int(item) for item in input().split()]
    As = sorted(As)

    turn = 0
    A = 0
    B = 0
    while As:
        if turn % 2 == 0:
            A += As.pop()
        else:
            B += As.pop()

        turn += 1
    print(A-B)




if __name__ == "__main__":
    resolve()


# Example run
# Input:
186251406
-133790981
# Output:
-133790981
n = int(input())
a = [int(x) for x in input().split()]
a.sort(reverse=True)

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

# Example run
# Input:
204095531
1
# Output:
1
n = int(input())
a = list(map(int, input().split()))
a.sort()
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:
-230914
-246934
# Output:
[-246934]
0
a = int(input())
b = list(map(int, input().split()))

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


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




# Example run
# Input:
1929
-7487220
# Output:
-7487220
N=int(input())
a = [int(x) for x in input().split()]
a.sort()
a.reverse()
j=0
k=0
for i in range(N):
    if i%2==0:
        j=j+a[i]
    else:
        k=k+a[i]
l=j-k
print(l)

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


card_list.sort(reverse = True)

alice_list = []
bob_list = []
if N % 2 == 0:
    for i in range(0, N, 2):
        alice_list.append(card_list[i])
    for i in range(1, N, 2):
        bob_list.append(card_list[i])
else:
    for i in range(0, N + 1, 2):
        alice_list.append(card_list[i])
    for i in range(1, N, 2):
        bob_list.append(card_list[i])


alice_score = sum(alice_list)
bob_score = sum(bob_list)

ans = alice_score - bob_score
print(ans)


# Example run
# Input:
-9
89
# Output:
0
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
scr_A=[]
scr_B=[]
for i in range(len(a)):
  if i%2==0:
    scr_A.append(a[i])
  else:
    scr_B.append(a[i])
print(sum(scr_A)-sum(scr_B))

# Example run
# Input:
-29749547
-337
# Output:
-337
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:
20
4436908
# Output:
4436908
N = int(input())
A = sorted(map(int, input().split()), reverse=True)

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


# Example run
# Input:
-640183291
155287
# Output:
155287
N = int(input())
A = int(input())
card_list = [A]
print(card_list)

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

# Example run
# Input:
e3zvshd]
45580
# Output:
45580
N=int(input()) 
a = list(map(int, input().split()))
sum=0
a.sort()
a.reverse()
if(N>2 and N%2 == 0):
  for i in range(0,N-1,2):
    sum=sum+a[i]-a[i+1]
if(N>2 and N%2 != 0):
  for i in range(0,N-1,2):
    sum=sum+a[i]-a[i+1]
  sum=sum+a[N-1]
elif(N==1):
  sum=a[0]
elif(N==2):
  sum=a[0]-a[1]
print(sum)

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

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

A.sort()
A.reverse()

Alice = 0
Bob = 0

for i, num in enumerate(A):
    if i//2 == 0:
        Alice += num
    else:
        Bob += num
        
print(Alice - Bob)

# Example run
# Input:
-104837
-69520
# Output:
-69520
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:
-87
141725276
# Output:
0
N = int(input())
A = [int(i) for i in 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:
1
4887419
# Output:
4887419
n=int(input())
a=[0]*n
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:
-274078593
-28418
# Output:
0
N = int(input())
# スペース区切りの整数の入力
a=[]
a = list(map(int, input().split()))
a.sort()
#print(a[::-1])
a=a[::-1]
i=0
sum=0
while i<len(a):
  if i%2==0:
    sum=sum+a[i]
  else:
    sum=sum-a[i]
  i=i+1

print(sum)

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

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


abc()


# Example run
# Input:
gR&
7
# Output:
7
#ABC088

m = int(input())
a = sorted(list(map(int,input().split())),reverse=True)
p = 0
q = 0
for i in range(len(a)//2):
    p += a[2 * i]
    q += a[2 * i + 1]

if len(a) % 2 != 0:
    p += a[-1]

print(p-q)




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

is_alice_turn = True

alice_point = 0
bob_point = 0

while len(A) != 0:
    picked_num = max(A)
    if is_alice_turn:
        alice_point += picked_num
    else:
        bob_point += picked_num

    A.remove(picked_num)
    is_alice_turn = not is_alice_turn

print(alice_point - bob_point)


# Example run
# Input:
38
-52564348
# Output:
-52564348
n=int(input())
lista=list(map(int,input().split()))
lista.sort()
alice=list()
bob=list()
for i in range(n):
    if i%2==0:
        alice.append(lista[i])
    else: 
        bob.append(lista[i])

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

# Example run
# Input:
-5654
161
# Output:
0