Felix6326727/beyond-accuracy-code-comprehension huggingface dataset:
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)

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

# Example run
# Input:
0
16
# Output:
16
#-*-cording:utf-8-*-
N = int(input())
A = input().split()
A.sort()
A.reverse()
a=list(map(int,A))
Alice = a[0::2]
Bob = a[1::2]
allA=sum(Alice)
allB=sum(Bob)
Ans=allA-allB
print(Ans)

# Example run
# Input:
37777
19239
# Output:
19239
#coding:utf-8

N = int(input())
a = list(map(int,input().split()))
a.sort()
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:
-224960337
446
# Output:
0
n = int(input())
a = list(map(int, input().split()))

alice = 0
bob = 0

a.sort(reverse = True)

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

	else:
		bob += a[i]

difference = alice - bob

print(difference)


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

a.sort()
a.reverse()

Alice = sum(a[i] for i in range(len(a)) if i % 2 == 0)
Bob = sum(a[i] for i in range(len(a)) if i % 2 == 1)

print(Alice - Bob)


# Example run
# Input:
470
499561877
# Output:
499561877
n=int(input())
A=[int(x) for x in input().split()]
B=sorted(A)
Alice=[]
Bob=[]
while len(B)!=0 and len(B)!=1:
  Alice.append(B[-1])
  B.pop()
  Bob.append(B[-1])
  B.pop()
if len(B)==1:
  Alice.append(B[0])
  B.pop()
print(sum(Alice)-sum(Bob))


# Example run
# Input:
-53605951
3
# Output:
3
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:
0
-2147483648
# Output:
-2147483648
int_n = int(input())
int_array = list(map(int, input().split()))

int_array.sort(reverse=True)

alice = int_array[::2]

bob = int_array[1::2]

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



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

# Example run
# Input:
-5075395
-156960
# Output:
156960
N = int(input())
a = list(map(int,input().split()))
a.sort()
a = a[::-1]
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:
-2540
-1836
# Output:
0
N = int(input())

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

for i in range(N):
   for j in reversed(range(i+1,N)):
        print(i,j)
        if a[j] > a[j-1]:
            temp = a[j]
            a[j] = a[j-1]
            a[j-1] = temp

Alice = 0
Bob = 0

k = 0
count =1
while k < N:
    if count % 2 == 0:
        Bob += a[k]
    else:
        Alice += a[k]
    k += 1
    count += 1

print(Alice-Bob)

# Example run
# Input:
-1800135697
415326
# Output:
0
def main():



    n = int(input())
    aList = list(map(int,input().split()))
    aList.sort(reverse=True)
    print(sum(aList[0::2])-sum(aList[1::2]))




if __name__ == "__main__":
    main()



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


a.sort(reverse=True)

sum1 = 0
sum2 = 0

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

for i in range(1, n, 2):
    sum2 += a[i]

print(sum1 - sum2)





# Example run
# Input:
-2811762
15761764
# Output:
0
# -*- coding: utf-8 -*-

import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

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

alice=0
bob=0

a.sort()

for i in range(n):
    if i%2==0:
        alice+=a.pop()
    else:
        bob+=a.pop()
print(alice-bob)


# Example run
# Input:
-3225
-5024207
# 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:
99959766
377
# Output:
377
temp=input()
temp=input()
A=[int(x) for x in temp.split()]
A.sort(reverse=True)

sum=0
for x in range(len(A)):
  sum=sum+(-1)**(x)*A[x]
print(sum)

# Example run
# Input:
^C:bAUMO[
2147483647
# Output:
2147483647
n = int(input())
a = sorted(map(int, input().split()), reverse=True)
print(2*sum(a[::2])-sum(a))


# Example run
# Input:
3197356
4889
# Output:
4889
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:
-1643990
363865392
# Output:
363865392
n = int(input())
c = [int(i) for i in input().split()]
c.sort(reverse=True)
a = []
b = []
for i in range(n):
    if i % 2 == 0:
        a.append(c[i])
    else:
        b.append(c[i])
print(sum(a) - sum(b))

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

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

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

a.sort(reverse=True)

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

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


# Example run
# Input:
JxHz
-4635017
# Output:
-4635017
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:
-86
0
# Output:
0
## coding: UTF-8
N = int(input())
A = [int(x) for x in input().split()]

#print(N)
#print(A)
A.sort(reverse=True) #大きい順に並べる
#print(A)

Alice = []
Bob = []

counter = 0

while True:
    if(len(A) == 0):
        break #リストの要素が全部取得されたらループを消す

    if(counter % 2 == 0): #first,third,...
        #x = A.pop(0)
        Alice.append(A.pop(0))
        counter += 1
    else:
        Bob.append(A.pop(0))
        counter += 1
    
#print(Alice)
#print(sum(Alice))
#print(Bob)
#print(sum(Bob))
print(sum(Alice) - sum(Bob))

# Example run
# Input:
-30
-54634663
# Output:
-54634663
def calc(al,bo,a):
  if len(al)-len(bo) != 0:
    bo.append(a)
  else :
    al.append(a)
  return al,bo
    
N=int(input())
a=input().split()
a=[int(k) for k in a]
a.sort()

alice = []
bob = []

while(N!=0):
  alice,bob = calc(alice,bob,a[N-1])
  N -= 1
  
print(sum(alice)-sum(bob))

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

p_a = sum(sorted(a, reverse = True)[::2])
p_b = sum(a) - p_a
print(p_a - p_b)


# Example run
# Input:
-39032
66169
# Output:
66169
n = int(input())
a = [int(s) for s in input().split()]

a.sort()
alice = 0
bob = 0
for i in range(n):
    if i % 2 == 0:
        alice += a[n-1-i]
    elif i % 2 == 1:
        bob += a[n-1-i]

print(alice - bob)


# Example run
# Input:
0
-54266464
# Output:
0
n = int(input())
a = list(map(int, input().split()))
sorted(a, reverse=True)
alice = 0
bob = 0
flag_alice = True
for num in a:
    print(num)
    if flag_alice:
        alice += num
        flag_alice = False
    else:
        bob += num
        flag_alice = True
print(alice - bob)


# Example run
# Input:
374
-838
# Output:
-838
-838
n = int(input())
A = list(sorted(list(map(int,input().split())))[::-1])
print(sum(A[::2])-sum(A[1:2]))


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

# Example run
# Input:
-65
0
# Output:
0
N = int(input())
a = [int(i) for i in input().split()]
a = sorted(a, reverse=True)
Alice = a[::2]
Bob = a[1::2]
print(sum(Alice)-sum(Bob))


# Example run
# Input:
-246934
-2
# Output:
-2
N = int(input())

a = [int(x) for x in input().split()]

a.sort(reverse=True)

ans = 0
tmp = 1
for ai in a:
    ans += tmp * ai
    tmp *= -1

print(ans)

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

# Example run
# Input:
-112
-246934
# Output:
-246934
n=int(input())
list=list(map(int,input().split()))
list.sort()
ans=0
for i in range(1,n+1):
  ans += (-1)**(i-1) * list[-i]
print(ans)

# Example run
# Input:
-5
36241
# Output:
0
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:
-9
89
# Output:
89
N = int(input())
B = list(map(int, input().split()))

one =[]
two =[]
count = 0
if N%2 ==0:
  while count <= N-1:
    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(one)
print(two)
print(sum(one)-sum(two))

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

# Example run
# Input:
38379
11
# Output:
11
n=int(input())
s=list(map(int,input().split()))
s=sorted(s,reverse=True)

#Alice,Bob
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:
-65906
8
# Output:
0
input();c=0
for a in sorted(map(int,input().split())):c=a-c
print(c)

# Example run
# Input:
o'Vh
-473
# Output:
-473
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
#print(a)
Alice=[]
Bob=[]
for i in range(n):
            if i%2==0:
                        Alice.append(a[i])
            else:
                        Bob.append(a[i])
#print('Alice',Alice)
#print('Bob',Bob)

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


# Example run
# Input:
-3550
-11385106
# Output:
0
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:
-740
1
# Output:
1
def main():
	N = int(input())
	a = list(map(int, input().split()))
	len_a = len(a)

	a.sort(reverse = True)

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

	print(Alice - Bob)

  
if __name__ == "__main__":
  	main()

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

alice = 0
bob = 0

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

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


# Example run
# Input:
-188803
-802253
# Output:
802253
n=int(input())
s=list(map(int,input().split()))
s.reverse()
sum=0
for i in range(n):
    if i%2==0:
        sum+=s[i]
    else:
        sum-=s[i]
print(int(sum))
        




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

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

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

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

a.sort()


alice = 0
bob = 0
flg = 0

while(len(a)>0):
    if flg == 0:
        alice += a.pop()
    elif flg ==1:
        bob += a.pop()
    flg = not(flg)

print(alice-bob)

# Example run
# Input:
14508349
-252699780
# Output:
-252699780
# 入力
N=int(input())
l=list(map(int,input().split()))

# 先攻：a  後攻：b
a=b=0

# 数字が大きい順にソート
l.sort()
l.reverse()

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

# 出力
print(a-b)

# Example run
# Input:
-24166826
-802253
# Output:
-802253
N = int(input())
a = sorted([int(x) for x in input().split()], reverse=True)

Alice = sum(a[i] for i in range(0,N,2))
Bob = sum(a) - Alice
print(Alice-Bob)


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


# Example run
# Input:
-22328
-489
# Output:
-489