Felix6326727/beyond-accuracy-code-comprehension huggingface dataset:
N=input()
A=list(map(int,input().split()))
A.sort(reverse=True)
print(sum(A[0::2])-sum(A[1::2]))

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

# Example run
# Input:
645801
559
# Output:
559
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:
-473
-7
# Output:
[-7]
0
n = int(input())
a = input().split()

a = list(map(int, a))

alice_n = a[::2]
bob_n = a[1::2]

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

# Example run
# Input:
-21
31499
# Output:
31499
count = int(input())
array = sorted(list(map(int, input().split())), reverse=True)
r = 0
i = 0
while i < count:
    if (i % 2) < 1:
        r += array[i]
    else:
        r -= array[i]
    i += 1
    
print(r)

# Example run
# Input:
-147
-3225
# Output:
0
n=int(input())
a= [int(i) for i in input().split()]
a.sort(reverse=True)

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

# Example run
# Input:
-260
-1628416575
# Output:
-1628416575
N=int(input())
a=list(map(int,input().split()))
a=sorted(a,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:
-2556
-80246
# Output:
0
n = int(input())
l = list(map(int, input().split()))
L = sorted(l, reverse=True)
a = 0
b = 0
for i in range(n):
  if i % 2 == 0:
    a = L[i] + a
  else:
    b = L[i] + b
print(a-b)

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

# Example run
# Input:
-958636
-536687537
# Output:
-536687537
def ABC_88_B():
    N=int(input())
    A = input().split()
    A = [int(s) for s in A]
    A.sort()
    alice=0
    bob=0

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

    print(abs(alice-bob))


if __name__ == '__main__':

    ABC_88_B()

# Example run
# Input:
0
33729406
# Output:
33729406
n=int(input())
a=list(map(int,input().split()))
a_sorted=sorted(a,reverse=True)
diff=0
if n%2==0:
  for i in range(n//2):
    diff+=a_sorted[2*i]-a_sorted[2*i+1]
  print(diff)
else:
  for i in range(n//2):
    diff+=a_sorted[2*i]-a_sorted[2*i+1]
  print(diff+a_sorted[-1])

# Example run
# Input:
-30
-54634663
# Output:
0
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:
-1787
199312
# Output:
0
N = int(input())
a_i = list(map(int, input().split(' ')))

x = []
y = []

if N%2==0:
    for j in range(int(N/2)):
        x.append(max(a_i))
        a_i.remove(max(a_i))
        y.append(max(a_i))
        a_i.remove(max(a_i))

else:
    for j in range(int((N/2)+1)):
        x.append(max(a_i))
        a_i.remove(max(a_i))
        if a_i == []:
            break
        y.append(max(a_i))
        a_i.remove(max(a_i))

X = sum(x)
Y = sum(y)


if X >= Y:
    print(X - Y)

else:
    print(Y - X)


# Example run
# Input:
439273
12
# Output:
12
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:
1+^6:
-76824657
# Output:
-76824657
# coding: utf-8

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

a = sorted(a, reverse=True)

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:
0
10
# Output:
0
n = int(input())
a_list = list(map(int, input().split()))
a_list.sort(reverse = True)

alice = 0
bob = 0

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

# Example run
# Input:
-1
-3439167
# Output:
0
#10
N = int(input())
x = list(map(int,input().split()))
alis = 0
bob = 0
cou = 0

x.sort()

for i in reversed(range(N)):
    if cou %2 == 0:
        alis += x[i]
    else:
        bob += x[i]
    cou += 1

print(alis - bob)
    

# Example run
# Input:
-3753932
42339391
# Output:
0
def main():
    n = int(input())
    a = list(map(int, input().split()))
    score = [0, 0]
    sort_a = sorted(a, reverse=True)

    for i in range(n):
        if i >= 2:
            sub_i = i % 2
        else:
            sub_i = i
        score[sub_i] += sort_a[i]

    print(score[0] - score[1])


if __name__ == "__main__":
    main()
    

# Example run
# Input:
-436344399
-83
# Output:
0
n = int(input())
nums = sorted(list(map(int, input().split(' '))), reverse=True)
bob = 0
alice = 0

for id, num in enumerate(nums):
    if id % 2 == 0:
        bob += num
    else:
        alice += num

print(bob - alice)


# Example run
# Input:
2
48477567
# Output:
48477567
n = int(input())
a = list(map(int,input().split()))
list.sort(a,reverse = True)
k = 0
l = 0

for i in range(n)[::2]:
    k += a[i]

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

print(k - l)


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

a = []
b = []
l.sort(reverse=True)
for i, r in enumerate(l, start=1):
    if i % 2 == 1:
        a.append(r)
    else:
        b.append(r)
print(sum(a) - sum(b))

# Example run
# Input:
m`%X
62
# Output:
62
# ABC 088: B – Card Game for Two
n = int(input())
a = [int(s) for s in input().split()]
a.sort()
a.reverse()

alice = 0
bob = 0

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

print(alice - bob)

# Example run
# Input:
11
-5185949
# Output:
-5185949
n = int(input())
a = list(map(int,input().split()))
alice = 0
bob = 0
for i in range(1,n+1):
  if i%2==1:
    alice += max(a)
    a.remove(max(a))
  else:
    bob += max(a)
    a.remove(max(a))
    
print(alice-bob)

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

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

alice = 0
bob = 0

a.sort(reverse=True)

for i, num in enumerate(a):
    if(i %2 == 0):
        alice += a[i]
    else:
        bob += a[i]
    
print(alice - bob)

# Example run
# Input:
28016
-48
# Output:
-48
N = int(input())
A = sorted(list(map(int,input().split())),reverse=True)

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

# Example run
# Input:
0
35
# Output:
35
n = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
i = 0
ans = 0

for num in a:
    if(i % 2 == 0):
        ans += num
    else:
        ans -= num
    i += 1

print(ans)

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


# Example run
# Input:
2563
2147483647
# Output:
2147483647
N=int(input())
a=sorted(map(int, input().split()), reverse=True)

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

print(pts[0]-pts[1])


# Example run
# Input:
-1469
-1164
# Output:
0
n = int(input())
L = sorted(list(map(int,input().split())),reverse = True)

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

#print(sum(L[::2]) - sum(L[1::2]))

# Example run
# Input:
-647437
346
# Output:
0
if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split(' ')))
    A.sort()
    Alice = 0
    Bob = 0
    turn = True
    for _ in range(N):
        if turn:
            Alice += A.pop()
            turn = False
        else:
            Bob += A.pop()
            turn = True
            
    print(abs(Alice - Bob))

# Example run
# Input:
0
2147483647
# Output:
0
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:
-56834839
1288
# Output:
0
n=int (input())
card=list(map(int, input().strip().split()))
card.sort(reverse=True)
a=0
b=0
for i in range(n):
    if i%2==0:
        a=a+card[i]
    elif i%2==1:
        b=b+card[i]
print(a-b)

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

# Example run
# Input:
331292818
1
# Output:
1
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())
  
n=i()
a=intl()
a.sort()
alice=0
bob=0
for i in range(1,n+1):
	if i%2==1:
		alice+=a[-i]
	else:
		bob+=a[-i]
print(alice-bob)

# Example run
# Input:
-37
1
# Output:
0
n = int(input())
a_list = sorted(list(map(int, input().split())), reverse=True)
alice = 0
bob = 0
for i, a in enumerate(a_list):
    if i % 2 == 0:
        alice += a
    else:
        bob += a
print(str(alice - bob))

# Example run
# Input:
0
11
# Output:
11
# B - Card Game for Two

N = int(input())
A = list(int(a) for a in input().split())
A.sort(reverse=True)

alice = 0
bob = 0

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

print(alice-bob)

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

# Example run
# Input:
3br
-55649
# Output:
-55649
N = int(input())
*A, = map(int, input().split())
A.sort(reverse=True)
Alice = 0
Bob   = 0
Alice = sum(A[0::2])
Bob   = sum(A[1::2])
print(Alice-Bob)

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

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

alice = 0
bob = 0

# ソート
a.sort(reverse=True)

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

print(alice - bob)

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

# Example run
# Input:
-56834839
1288
# Output:
0
n = int(input())
X = list(map(int, input().split(' ')))

X.sort()

x = sum(X)
b = sum(X[0::2])
a = x - b

print(a-b)

# Example run
# Input:
-3753932
42339391
# Output:
-42339391
#!/usr/bin/env python3

def main(N, a):
    alis_score = sum(a[0::2])
    bob_score = sum(a[1::2])

    print(alis_score - bob_score)

if __name__ == '__main__':
    N = int(input())
    a = list(map(int, (input().split())))
    main(N, sorted(a, reverse=True))


# Example run
# Input:
3
-1
# Output:
-1
N = int(input())
A = int(input())
print(A)

# Example run
# Input:
5
-893630
# Output:
-893630
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:
692048
-10
# Output:
-10
N = int(input())
A = list(map(int, input().split()))

A = sorted(A, reverse=True)

alice = 0
bob = 0

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


print(alice - bob)


# Example run
# Input:
-55768
55
# Output:
55
N = int(input())
line = list(map(int, input().split()))
line.sort(reverse=True)
ans = 0
i = 0
while line:
    p = line.pop(0)
    if i % 2 == 0:
        ans += p
    else:
        ans -= p
    i += 1

print(ans)

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

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

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

print(abs(alice-bob))


# Example run
# Input:
-33
-7497549
# Output:
7497549
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
A=0
B=0
while len(a) >=1:
    A += a.pop(0)
    if len(a)==0:
        break
    B += a.pop(0)
print(A-B)

# Example run
# Input:
-18644718
-30134546
# Output:
-30134546
N=int(input())
a=sorted(list(map(int,input().split(' '))),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:
-1051
-27
# Output:
0
N = int(input())
M = map(int,input().split())

M = sorted(M)

alice = 0
bob = 0

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

# Example run
# Input:
-89083
-3339504
# Output:
0
N = int(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:
0
985477
# Output:
985477
n=int(input())
a=map(int,input().split())
sort_a=sorted(a)

alice = sum(sort_a[::2])
bob = sum(sort_a[1::2])

print(alice - bob)  

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

a.sort(reverse=True)

s = sum(a)
al = sum(a[::2])
bo = s - al
print(abs(al-bo))

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

# Example run
# Input:
15927431
141
# Output:
141
# cook your dish here
n=int(input())	
a = list(map(int,input().split()))

if n %2 !=0:
    a.append(0)
    n = n+1
    
a.sort()
b = a[::-1]

c=0
d=0


k = 0
while k != n:
   c += b[k]
   d += b[k+1]
   k = k +2
print(c-d)

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

alice = 0
bob = 0

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

print (alice - bob)

# Example run
# Input:
-15915
-501843
# Output:
0
import sys

def main():
    n = int(input())
    a = sorted(list(map(int, input().split())), reverse=True)
    print(counter(n, a))

def counter(n, a):
    return sum(a[::2]) - sum(a[1::2])

if __name__ == '__main__':
    main()


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

# Example run
# Input:
-7038374
-6
# Output:
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:
-91379208
255282273
# Output:
255282273
N=int(input())
a = list(map(int,input().split()))

a.sort();
result = 0;

for i in range(N):
    result += a[i]*(-1)**i

print(abs(result))

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

alice = 0
bob = 0

for i in range((len(a) + 1 )// 2) :
    alice += max(a)
    a.remove(max(a))
    if len(a) != 0 :
        bob += max(a)
        a.remove(max(a))
print(alice - bob)

# Example run
# Input:
0
-6956
# Output:
-6956
N=int(input())
A=[]
A_before=input().split(' ')
for i in range(len(A_before)):
  A.append(int(A_before[i]))
for i in range(len(A)):
  for j in range(len(A)-1):
    if A[j]<A[j+1]:
      x=A[j]
      A[j]=A[j+1]
      A[j+1]=x
a=0
b=0
for i in range(len(A)):
  if i%2==0:
    a=a+A[i]
  else:
    b=b+A[i]
print(a-b)


# Example run
# Input:
72781634
-501810
# Output:
-501810
# solution
import io

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

# Example run
# Input:
S43brt#
104248
# Output:
104248
n=int(input())
li=list(map(int,input().split()))
newli=sorted(li)
gu=[]
ki=[]
for i in range(n):
  if i%2==0:
    gu.append(newli[-(i+1)])
  else:
    ki.append(newli[-(i+1)])
print(sum(gu)-sum(ki))


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

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

# Example run
# Input:
-2314351
3986
# Output:
0
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:
3
-264371717
# Output:
-264371717
"""
Created on Wed Jan  1 17:06:59 2020
"""

n = int(input())
l = list(map(int, input().split()))
l.sort()
l.reverse()
a = 0
b = 0
for i in range(n):
    if i % 2 == 0:
        a += l[i]
    else:
        b += l[i]
print(a - b)


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

Alice = 0
Bob = 0
A.sort(reverse=True)

if N%2 == 0:
    for i in range(int(N/2)):
        Alice += A[2*i]
        Bob += A[2*i+1]
        print(Alice-Bob)
        
else:
    for i in range(int((N-1)/2)):
        Alice += A[2*i]
        Bob += A[2*i+1]
    Alice += A[-1]
    print(Alice-Bob)



# Example run
# Input:
-31
-58867430
# Output:
-58867430
num = int(input())
n= list(map(int,input().split()))
Alice = 0
Bob = 0

n = sorted(n, reverse=True)

f= n[::2]
s = n[1::2]

for i in range(len(f)):
    Alice += int(f[i])
    
for j in range(len(s)):
    Bob += int(s[j])
#print(n)
#print(Alice)
#print(Bob)
print(int(Alice)-int(Bob))



# Example run
# Input:
15761764
-37
# Output:
-37
def main():
    N = int(input())
    a = list(map(int,input().split()))
    Alice = 0
    Alice_j = True
    Bob = 0
    Bob_j = False
    a.sort(reverse = True )
    for i in range(N):
        if Alice_j == True:
            Alice += a[i]
            Alice_j = False
            Bob_j = True
        elif Bob_j == True:
            Bob += a[i]
            Bob_j = False
            Alice_j = True
    return Alice - Bob

print(main())


# Example run
# Input:
-13
7381
# Output:
0
N = int(input())
card_values = list(map(int, input().split(" ")))
 
card_values_sorted = sorted(card_values, reverse=True)

Alice_score = 0
Bob_score = 0
for i in range(N):
    if i%2 == 0:
        Alice_score += card_values_sorted[i]
    else:
        Bob_score += card_values_sorted[i]
 
print(Alice_score - Bob_score)

# Example run
# Input:
-1
-3439167
# Output:
0
Num = int(input())
Num_Array = list(map(int,input().split()))
Alice,Bob = 0,0

for i in range ( Num ):
    Check_Max = -1

    for x in range(len(Num_Array)):
        if Num_Array[x] > Check_Max :
            Check_Max = Num_Array[x]
            check = x

    Num_Array.pop(check)

    if i % 2 == 0 :
        Alice += Check_Max
    else:
        Bob += Check_Max

print(Alice - Bob)

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

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

count = 0
for i in range(len(a)//2):
    count+=a[2*i+1]-a[2*i]
print(count)

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

print(abs(a-b))

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

# Example run
# Input:
57273801
-98031
# Output:
-98031
N=int(input())
A=input()

A_list = A.split(" ")
map(int,A_list)

A_list.sort()
A_list.reverse()

alice=0
bob=0

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

print(alice-bob)

# Example run
# Input:
-1
2575588
# Output:
2575588
n = int(input())
A = list(map(int, input().split()))
A.sort()
A.reverse()
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:
-5271130
19
# Output:
0
def solve():
    n = int(input())
    a = map(int, input().split())

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

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

    print(alice - bob)

solve()

# Example run
# Input:
-11385106
-114
# Output:
-114
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:
-1005173
-60875
# Output:
0
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
sumA = 0
sumB = 0

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

print(sumA-sumB)


# Example run
# Input:
-66
-929
# Output:
-929
def main():
    input()
    a = list(map(int, input().split()))
    a = sorted(a, key=lambda x: -x)
    print(sum(a[::2]) - sum(a[1::2]))


if __name__ == '__main__':
    main()


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

# Example run
# Input:
3081428
-194
# Output:
-194
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:
-9057988
-204485211
# 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.pop(0)
    else:
        bob += A.pop(0)
print(alice-bob)

# Example run
# Input:
-155785153
-104837
# Output:
0
N = int(input())
A = [int(v) for v in input().split()]
A.sort()

Alice = 0
Bob = 0
for i, v in enumerate(A[::-1]):
  if i % 2 == 0:
    Alice += v
  else:
    Bob += v
print(Alice - Bob)

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

Alice = 0
Bob = 0

#降順に並べることが完了
ld = sorted(a, reverse=True)

Alice = ld[:: 2]
# print(Alice)

Bob = ld[1:: 2]
# print(Bob)

Alice_a = sum(Alice)
Bob_a = sum(Bob)


print(Alice_a - Bob_a)

# Example run
# Input:
-48655
32683
# Output:
32683
# ソート
# Greedy
N = int(input().rstrip())
a = sorted([int(i) for i in input().rstrip().split(' ')], reverse=True)
print(sum(a[::2]) - sum(a[1::2]))

# Example run
# Input:
237
-42600
# Output:
-42600
n=int(input())
a=list(map(int,input().split()))
a=sorted(a,reverse=True)
s=[]
t=[]
s.append(a[0::2])
t.append(a[1::2])

print(sum(s[0])-sum(t[0]))

# Example run
# Input:
627
5460
# Output:
5460
n = int(input())
l = list(map(int,input().split()))
alice = 0
bob = 0

l.sort(reverse = True)

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


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

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

print(alice - bob)  

# Example run
# Input:
197766
-101281970
# Output:
-101281970
# 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:
0
8131
# Output:
0
N = int(input())
a = map(int, input().split())

l = sorted(a, reverse=True)
Alice = sum(l[::2])
Bob = sum(l[1::2])


print(Alice - Bob)


# Example run
# Input:
57223618
-62350830
# Output:
-62350830
n=int(input())
a = list(map(int, input().split()))
a.sort()
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:
-3733491
0
# Output:
0
N = int(input())
a = [int(x) for x in input().split()]

a.sort()
a.reverse()

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:
1
2213134
# Output:
2213134