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

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

# Example run
# Input:
-15
-253690
# Output:
-253690
num=int(input())
values=[int(str) for str in input().split()]

values=sorted(values,reverse=True)


sumA=0
sumB=0
for i,val in enumerate(values):
    if i%2==0:
        sumA+=val
    else:
        sumB+=val

print(sumA-sumB)

# Example run
# Input:
-117864
-38181262
# Output:
-38181262
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
ans=0
for i in range(0,n,2):
  ans+=i
for i in range(1,n,2):
  ans-=i
print(ans)

# Example run
# Input:
107
186860433
# Output:
53
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:
-11989124
-407
# Output:
0
N=int(input())
a=[int(s) for s in input().split(" ") ]

a.sort()
Alice=0
Bob=0
while len(a)>=1:
    Alice+=a[-1]
    a.pop(-1)
    if len(a)>=1:
        Bob+=a[-1]
        a.pop(-1)

print(Alice-Bob)

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

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

# Example run
# Input:
z,sS*<;]?
-560878
# Output:
-560878
n = int(input())
l = list(map(int, input().split()))
l.sort(reverse = True)
i = 0
a = 0
b = 0
while i < n: 
    a = a +l[i]
    i += 2
i = 1
while i < n:
    b = b +l[i]
    i += 2
print(a -b)

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

a = sorted(a, reverse=True)
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:
-6
-1138
# Output:
-1138
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
print(sum(a[::2]) - sum(a[1::2]))

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

# Example run
# Input:
-42600
2116
# Output:
0
N = int(input())
alist = input().split()
alist = sorted(alist, reverse=True)
count = 1
alice = 0
bob = 0

for a in alist:
    if count % 2:
        alice += int(a)
    else:
        bob += int(a)
    count+=1
print(alice - bob)

# Example run
# Input:
-960
4345
# Output:
4345
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]
print(Alice - Bob)

# Example run
# Input:
-109089799
-74270783
# Output:
0
N = int(input())
A = sorted(list(int(i) for i in 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:
-512
1
# Output:
0
n = input()
a = sorted([int(x) for x in input().split()], reverse=True)
even, odd = 0,0,
for i in a[::2]:
    even += i
for i in a[1::2]:
    odd += i
print(even-odd)

# Example run
# Input:
(s?
-145
# Output:
-145
N=int(input())
a=[int(i) for i in input().split()]
A=B=0
a.sort(reverse=True)
for i in range(N):
    if i%2==0:
        A+=a[i]
    else:
        B+=a[i]
    a[i]=0
print(A-B)

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



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

for i in range(N):
    if i%2 == 0:
        Amax += max(A)
        A.remove(max(A))
    else:
        Bmax += max(A)
        A.remove(max(A))

print(Amax - Bmax)


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


# Example run
# Input:
-4816
-4
# Output:
[-4]
n = int(input()) 
ai = input().split()
ai = list(map(int, ai))

sorted_ai = sorted(ai, reverse=True)

alice = 0
bob = 0

for index, x in enumerate(sorted_ai):
    if (index % 2 == 0):
        alice += x
    else:
        bob += x
        
print(alice - bob)

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


# Example run
# Input:
-18991721
465
# Output:
465
n = int(input())
alice = 0
bob = 0

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

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:
-27566650
49968
# Output:
0
import heapq

N = int(input())
A = [-int(x) for x in input().split()]
ans=0
j=-1
heapq.heapify(A)

for i in range(N):
    ans +=heapq.heappop(A)*j
    j*=-1
    
print(ans)

# Example run
# Input:
-11385106
-114
# Output:
0
n = int(input())
a = list(map(int, input().split()))
ans = 0
a.sort(reverse = True)
print(a)

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

print(ans)

# Example run
# Input:
-6325
1
# Output:
[1]
1
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]

print(alice - bob)


# Example run
# Input:
-1
-3439167
# Output:
0
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	n = int(input())
	#b , c = tin()
	#s = input()
	al=lin()
	al.sort(reverse=True)
	return sum(al)-(2*sum(al[1::2]))
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

# Example run
# Input:
1595240
123
# Output:
123
N=int(input())
cardmap=map(int,input().split())
card=list(cardmap)
card.sort(reverse=True)
Alist=card[0::2]
Blist=card[1::2]
Asum=sum(Alist)
Bsum=sum(Blist)
print(Asum-Bsum)

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

a.sort()
a.reverse()


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

print(alice - bob) 


# Example run
# Input:
-54634663
3615919
# Output:
0
N = int(input())
arr = list(map(int, input().split()))
new_arr = sorted(arr, reverse=True)

bob   = 0
alice = 0

for i in range(len(new_arr)):
    if i % 2 ==0:
        alice += new_arr[i]
    elif i % 2 ==1:
        bob += new_arr[i]

print(alice-bob)

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

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


# Example run
# Input:
1
4887419
# Output:
4887419
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a_sort = sorted(a, reverse=True)
    alice = 0
    bob = 0
    for i in range(n):
        print(i)
        if i % 2 == 0:
            alice += a_sort[i]
        else:
            bob += a_sort[i]
    res = alice - bob
    print(res)
if __name__ == '__main__':
    main()

# Example run
# Input:
-32942311
298151
# 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:
-1965718821
-1
# Output:
-1
N = int(input())
a = sorted(map(int, input().split()))
print(abs(sum(a[1::2]) - sum(a[::2])))

# Example run
# Input:
0
-6956
# Output:
6956
n=int(input())
l=[int(i) for i in input().split()]
ans=sum(l)
l.sort()
for i in range(-2,-n-1,-2):
    ans-=l[i]*2
print(ans)

# Example run
# Input:
-109749
18575536
# Output:
18575536
N = int(input())
A = list(map(int, 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:
2147483647
71
# Output:
71
n = int(input())
A = [int(i) for i in input().split()]
A.sort(reverse = True)
x = A[::2]
print(sum(x) - (sum(A) - sum(x)))

# Example run
# Input:
-1
30456987
# Output:
30456987
N = int(input())
a = list(map(int, input().split()))
a.sort()
a.reverse()
Alice = 0
Bob = 0
for i in range(0, len(a), 2):
        Alice += a[i]
        
for i in range(1, len(a), 2):
        Bob += a[i]

print(Alice-Bob)

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

aliceSum = sum(cards[-1::-2])
bobSum = sum(cards[-2::-2])

print(aliceSum - bobSum)

# Example run
# Input:
23
493
# Output:
493
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:
-11989124
-407
# Output:
-407
n = int(input())
num_list = list(map(int, input().split()))

Alice = 0
Bob = 0

num_list.sort(reverse=True)
for i, num in enumerate(num_list):
    if i % 2 == 0:
        Alice += num
    else:
        Bob += num

print(Alice - Bob)


# Example run
# Input:
7
-36866075
# Output:
-36866075
a = int(input())
b = list(map(int, input().split()))
b = sorted(b, reverse=True)
c = [0, 0]
d = [1, 0]
e = [0, 1]
for i in range(a):
    c[0] += b[i] * d[i % 2]
    c[1] += b[i] * e[i % 2]
print(abs(c[0] - c[1]))



# Example run
# Input:
-23909
-68
# Output:
0
N=int(input())
lista=[int(x) for x in input().split()]

lista.sort(reverse=True)

A=B=0

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

# Example run
# Input:
-21000
3
# Output:
3
N = int(input())
P1 = 0
P2 = 0

arr = list(map(int, input().strip().split()))
arr = sorted(arr)

for i in range(0,len(arr)):
  if i%2 == 0:
    P1 = P1+arr[i]
  elif i%2 ==1:
    P2 = P2+arr[i]
print(abs(P2-P1))

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

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

a.sort(reverse=True)

A,B=0,0

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

print(A-B)


# Example run
# Input:
-7339797
-6
# Output:
0
n = int(input())
card = list(map(int, input().split()))

card.sort()
card.reverse()

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

print (a-b)

# Example run
# Input:
-812896393
-97075663
# Output:
0
n = int(input())
ls = sorted(list(map(int, input().split())))
Alice = 0
Bob = 0

while len(ls) != 0: 
    Alice += ls.pop()
    if len(ls) == 0:
        break
    Bob += ls.pop()
print(Alice - Bob)

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

# 並び替える
a = sorted(a, reverse=True)

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


if alice > bob:
    print(alice - bob)
else:
    print(bob-alice)


# Example run
# Input:
627
5460
# Output:
5460
n = int(input())
a = [int(_) for _ in input().split()]
if n % 2:
    a.append(0)

a.sort()

alice = 0
bob = 0

while len(a) > 0:
    alice += a.pop()
    bob += a.pop()

print(str(alice-bob))

# Example run
# Input:
-4705
-2410709
# Output:
2410709
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:
4345
-8164991
# Output:
-8164991
N = int(input())
A = map(int,input().split())

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

alice = 0
bob = 0

for i in range(N//2):
    alice += A[2*i]
    bob += A[2*i+1]
    
if N%2 == 1:
    alice += A[N-1]
    
print(alice-bob)

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

al = 0
bo = 0

for i in range(len(tmp)):
  if i %2 == 0:
    al = al + int(tmp[i])

  else:
    bo = bo + int(tmp[i])

print(al - bo)

# Example run
# Input:
f}C#D\QF
-260
# Output:
-260
n=int(input())
a_list=list(input().split())
 
a = 0
b = 0
a_list_sorted = a_list.sort(reverse=True)
 
for i in range(len(a_list)):
    if i % 2 == 0:
        a += int(a_list[i])
#         print(a)
    else:
        b += int(a_list[i])
#         print(b)
print(a-b)

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


A = sorted(A, reverse=True)

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

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

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

# Example run
# Input:
29367590
-6
# Output:
-6
N=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
b=[]
if len(a)%2==0:
    for i in range(0,(len(a)//2)):
        b.append(a[2*i]-a[2*i+1])
else:
    for i in range(0,(len(a)//2)):
        b.append(a[2*i]-a[2*i+1])
    b.append(a[len(a)-1])
print(sum(b))

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

a.sort()
a = a[::-1]

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:
-17760757
992
# Output:
0
from math import ceil
n = int(input())
a = map(int, input().split())
a = sorted(a,reverse=True)
ans = 0
for i,j in enumerate(a):
    if i % 2 == 0: ans += j
    else: ans -= j
print(ans)

# Example run
# Input:
-31
-58867430
# Output:
-58867430
N = int(input())
*a, = map(int, input().split())
a.sort(reverse=True)
print(sum(a[::2]) - sum(a[1::2]))

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

A = sorted(A, reverse=True)
Alice = 0
Bob = 0
for n in range(N):
    if n % 2 == 0:
        Alice += A[n]
    else:
        Bob += A[n]

print(Alice - Bob)

# Example run
# Input:
-19
-20238871
# Output:
0
N = int(input())

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

data = sorted(L, reverse=True)
count_A = 0
count_B = 0

for i, d in enumerate(data):
    if i%2 == 0:
        count_A += d
    else:
        count_B += d
        
print(count_A - count_B)

# Example run
# Input:
941
-57594492
# Output:
-57594492
n = int(input())
x = input().split()
y = []
for i in x:
  y.append(int(i))
y.sort(reverse=True)
a = 0
b = 0
for i in range(0, n):
  if i % 2 == 0:
    a += int(y[i])
  else:
    b += int(y[i])
print(a - b)

# Example run
# Input:
-554740
65444
# Output:
0
#coding: utf-8

def first_pop(l):
    if (len(l) <= 0):
        return 0
    else:
        return l.pop(0)

if __name__ == '__main__':

    n = int(input())
    a = sorted(map(int, (input().split())), reverse=True)
    alice, bob = 0, 0
    while len(a) > 0:
        alice += first_pop(a)
        bob += first_pop(a)

    print(alice - bob)

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

a.sort(reverse=True)

M = 0
m = 0

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

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

print(M-m)


# Example run
# Input:
-1
0
# Output:
0
N = int(input())
A = list(map(int, input().split()))
alice, bob = 0, 0
while(True):
    alice += max(A)
    A.remove(max(A))
    if not A: break
    bob += max(A)
    A.remove(max(A))
    if not A: break
print(alice - bob)


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

a.sort(reverse=True)
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:
5460
2
# Output:
2
N = int(input())
A = list(map(int, input().split()))
A.sort()
A.reverse()
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:
-208107
-83
# Output:
0
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:
-7487220
-1005
# Output:
0
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:
-72091561
-1622400
# Output:
-1622400
N = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
A = sum(a[0::2])
B = sum(a[1::2])
print(A-B)

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


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

# Example run
# Input:
-256478906
-8056
# 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:
-2
-497
# Output:
-497
n =int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
ans = 0
for i in range(n):
  if i%2 == 0:
    ans += a[i]
  else:
    ans -= a[i]
print(ans)

# Example run
# Input:
-318594
-13
# Output:
0
n = int(input())
a = [int(_) for _ in input().split()]
a.sort(reverse=True)
print( sum(a[::2])-sum(a[1::2]))

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

for i in range(N):
    ans=sum([a[i]*((-1)**i) for i in range(N)])
print(ans)

# Example run
# Input:
1
4887419
# Output:
4887419
N = int(input())
card = list(map(int,input().split()))
sorted_card = sorted(card)
Alice = 0
Bob = 0

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

print(Alice - Bob)

# Example run
# Input:
-2540
-1836
# Output:
0
N = int(input())
A = list(map(int, input().split()))
sum1=0
sum2=0
for num in range(N):
  if num % 2 == 0:
    sum1 += A[num]
  else:
    sum2 += A[num]
print(sum1 - sum2)

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

A.sort(reverse=True)

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

print(res)

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

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

# Example run
# Input:
D/+AUfX_C
1169288485
# Output:
1169288485
n = int(input())
c = sorted(list(map(int, input().split())))
print(sum(c[0::2]) - sum(c[1::2]))

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

a = list(reversed(sorted(a)))

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

print(ans)


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

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

print(ans)


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

# Example run
# Input:
3*p|@`(
-18231
# Output:
-18231
N = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
print(sum(a[0:N:2])-sum(a[1:N:2]))

# Example run
# Input:
-17
-3786437
# Output:
0
N = int(input())
A = sorted([a for a in map(int,input().split())], reverse=True)

flag = 0
Alice = 0
Bob = 0
for a in A:
    if flag==0:
        Alice += a
        flag = 1
    elif flag==1:
        Bob += a
        flag = 0
print(abs(Alice-Bob))

# Example run
# Input:
-2314351
3986
# Output:
3986
N = int(input())
a = list(map(int, input().split()))
a.sort()
a = a[::-1]
alice = 0
bob = 0
i = 0
while i < len(a):
    alice += a[i]
    i += 1
    if i >= len(a):
        break
    bob += a[i]
    i += 1
print(alice - bob)

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

# Example run
# Input:
-2147483648
-3528
# Output:
0
n = int(input())
a = [int(m) for m in input().split(" ")]

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

# Example run
# Input:
2147483647
1270
# Output:
1270
n = int(input())
a = [int(s) for s in input().split()]
a.sort(reverse=True)
alice = sum(a[0:n:2])
bob = sum(a[1:n:2])

print(alice - bob)

# Example run
# Input:
66907706
3425848
# Output:
3425848
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:
-259420352
376395
# Output:
0
n = int(input())
A = list(map(int,input().split()))
A_0 = A.sort(reverse=True)
swt = 0
Alice_point = 0
Bob_point = 0

for i in range(n):
    if swt == 0:
        Alice_point += A[i]
        swt = 1
    else:
        Bob_point += A[i]
        swt = 0
print(Alice_point - Bob_point)


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

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


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

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

print(ret)

# Example run
# Input:
-166
2
# Output:
0
_ = input()
xs = sorted([int(x) for x in input().split()], reverse=True)
print(abs(sum(xs[::2]) - sum(xs[1::2])))

# Example run
# Input:
}\pKT8\G
1045432
# Output:
1045432
n = int(input())
a = sorted(list(map(int, input().split())), reverse = True)

alice = 0
bob = 0

i = 0
lim = n // 2 * 2

while i < lim:
    alice += a[i]
    bob += a[i+1]
    i += 2

if n % 2 == 1:
    alice += a[n-1]

print(alice-bob)

# Example run
# Input:
-24
-35784
# Output:
0
N = int(input())
a_list = list(map(int, input().split()))
a_list.sort(reverse=True)

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


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

# Example run
# Input:
805965556
-19
# Output:
-19
N = int(input())
A = list(map(int,input().split()))
SA = sorted(A,reverse=True)
print(SA)
print(SA[0])
print(N)
ALI =0
BOB=0
for i in range(0,N,2):
    ALI += int(SA[i])
for n in range(1,N,2):
    BOB += int(SA[n])
print(ALI)
print(BOB)
ans = ALI - BOB
print(ans)

# Example run
# Input:
-25867257
-2147483648
# Output:
[-2147483648]
-2147483648
-25867257
0
0
0