Felix6326727/beyond-accuracy-code-comprehension huggingface dataset:
N = int(input())
array = list(map(int, input().split()))
array.sort()
sum_1 = 0
sum_2 = 0

for i in range(N):
    if i % 2 == 0:
        sum_1 += array[-1]
        array.pop(-1)
        
    else:
        sum_2 += array[-1]
        array.pop(-1)
print(sum_1 - sum_2)


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

# Example run
# Input:
My>_*s
-15015728
# Output:
-15015728
N = int(input())
List = list(map(int, input().split()))

List.sort(reverse = True)
Alice = List[::2]
Bob = List[1::2]
print(sum(Alice) - sum(Bob))

# Example run
# Input:
0
227
# Output:
227
n = int(input())
cards = [int(i) for i in input().split()]
cards.sort(reverse=True)
a = 0
b = 0
for i, num in enumerate(cards):
    if(i % 2 == 0):
        a = a + num
    else:
        b = b + num
print(a - b)


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

a.sort()
a.reverse()

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


# Example run
# Input:
7987516
0
# 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:
0
-2147483648
# Output:
-2147483648
N = int(input())
a = [int(x) for x in input().split()]
a_order = sorted(a, reverse=True)
alice, bob = 0, 0

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

# Example run
# Input:
-3391654
-274078593
# Output:
0
# -*- coding: utf-8 -*-
N = int(input())
a = list(map(int, input().split()))


sorted_a = sorted(a,reverse=True)

bob=0
alice=0

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

print(alice-bob)

# Example run
# Input:
-18231
54
# Output:
0
n = int(input())
a = sorted([int(_) for _ in input().split()], reverse=True)

m = sum([n for i, n in enumerate(a) if i%2 == 0])

print(2*m - sum(a))


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


# Example run
# Input:
C;'b#?l.
10
# Output:
10
n = int( input())
a = list(map(int, input().split()))
a = list(reversed(sorted(a)))
first = 0
second = 0
for i in range(0, n, 2):
      first += a[i]
for i in range(1, n, 2):
     second += a[i]
print(first - second)

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

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

# Example run
# Input:
0
11
# Output:
11
N = int(input())
aN = list(map(int, input().split()))

# 最適な戦略：Aliceは大きな数字から取っていく
Alice = []
Bob = []
for i in range((N + 1) // 2):
  # Aliceがカードを取る
  max_val = max(aN)
  Alice.append(max_val)
  aN.remove(max_val)
  if len(aN) > 0:
    # Aliceがカードを取った後Bobがカードを取る
    max_val = max(aN)
    Bob.append(max_val)
    aN.remove(max_val)

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


# Example run
# Input:
-450
139
# Output:
0
n = int(input())
a = list(map(int, input().split()))
al, bo = [], []
for i in range(n):
	if i % 2 == 0:
		al.append(max(a))
		a.remove(max(a))
	elif i % 2 == 1:
		bo.append(max(a))
		a.remove(max(a))
print(sum(al)-sum(bo))


# Example run
# Input:
-34
3
# Output:
0
N = int(input())
n_list = [int(i) for i in input().split(" ")]

n_list.sort()
sorted_list = n_list[::-1]

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

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



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

alice = 0
bob = 0
order = "A"
for e in sorted(a)[::-1]:
    if order == "A":
        alice += e
        order = "B"
    else:
        bob += e
        order = "A"

print(alice-bob)

# Example run
# Input:
605260
5101803
# Output:
5101803
N = int(input())
A = list(map(int, input().split()))
A.sort(key=lambda x: -x)
print(sum(A[0::2]))

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

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

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

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

print(alice-bob)

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

# Example run
# Input:
54353
49391
# Output:
49391
N = int(input())
a = list(sorted(map(int, input().split())))[::-1]
if N % 2 == 1:
    a += [0]
print(sum(a[::2]) - sum(a[1::2]))


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

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

# Example run
# Input:
-235202
-473
# Output:
-473
N = int(input())
num_list = [int(e) for e in input().split()]

S = sorted(num_list, reverse=True)

Alice = S[::2]
Bob = S[1::2]

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



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

a_sort = sorted(a, reverse=True)

Asum = 0
Bsum = 0

for i in range(1, N+1):
  if i%2 != 0:
    Asum += a_sort[i-1]
  else:
    Bsum += a_sort[i-1]

print(Asum-Bsum)

# Example run
# Input:
-324125621
-294226159
# Output:
0
# -*- coding:utf-8 -*-

N = int(input())
a_arr = [int(i) for i in input().split()]
a_arr2 = sorted(a_arr, reverse=True)
Alice = []
Bob = []

for j in range(len(a_arr2)):
  if j % 2 == 0:
    Alice.append(a_arr2[j])
  else:
    Bob.append(a_arr2[j])

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

# Example run
# Input:
8312590
601
# Output:
601
N = int(input())
An = list(map(int,input().split()))
An.sort(reverse=True)
alice = 0
bob = 0
for i in range(N):
    if i % 2 == 0:
        alice += An[i]
    else:  
        bob += An[i]
answer = alice - bob
print(answer)


# Example run
# Input:
-28
-512
# 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:
-8886
-7148954
# Output:
-7148954
input()
a = sorted(list(map(int,input().split())))
print(sum(a[-1::-2])-sum(a[-2::-2]))

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

# Example run
# Input:
-1
-3439167
# Output:
-3439167
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:
-3249
901872
# Output:
0
N=int(input())
A=sorted(map(int,input().split()))[::-1]
print(sum(A[::2])*2-sum(A))

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

# Example run
# Input:
41555
587245588
# Output:
587245588
# -*- coding: utf-8 -*-

N = int(input())
AList = list(map(int, input().split()))

AList.sort()
AList.reverse()

alice = 0
bob = 0

count = 0
for a in AList :
    if (count % 2) == 0 :
        alice += a
    else :
        bob += a
    count += 1

print(alice-bob)

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

def sum(a):
    max_value = max(a)
    ind = a.index(max_value)
    a[ind] = 0
    return a,max_value

Asum = 0
Bsum = 0
max_value = 100
while max_value > 0:
    a,max_value = sum(a)
    Asum += max_value
    a,max_value = sum(a)
    Bsum += max_value

print(Asum - Bsum)

# Example run
# Input:
98
5881
# Output:
5881
N = int(input())
a = list( map( int, input().split()))
a = sorted(a)
Alice = 0
Bob = 0
a.append(0)

for i in range(N//2 + 1):
	Alice += int(a[2 * i])  
	Bob += int(a[2 * i + 1])
    
print(Alice -Bob)

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

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

print(ans)

# Example run
# Input:
83
471619987
# Output:
471619987
N = int(input())
a = [int(_) for _ in input().split()]

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


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

# Example run
# Input:
18985674
213
# Output:
213
N = int(input())
a = list(map(int,input().split()))
A=0
B = 0
a.sort(reverse=True)
for i in range(0,N,2):
    A += a[i]
for i in range(1,N,2):
    B += a[i]
ans = A - B
print(ans)


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

    
print(sum)


# Example run
# Input:
-5056872
2072477
# Output:
0
n = int(input())
x = list(map(int, input().split()))
a=0
b=0
x.sort(reverse=True)
for i in range(int(n/2)):
    a += x[i*2]
    b += x[i*2+1]
if n%2==1:
    a+=x[n-1]
print(a-b)

# Example run
# Input:
-69520
-73864104
# Output:
0
input()
A = list(map(int,input().split()))
A.sort(reverse=1)
Alice = sum(A[::2])
Bob = sum(A[1::2])
print(Alice-Bob)



# Example run
# Input:
an8/8]u
-1057486868
# Output:
-1057486868
n=int(input())
a=map(int,input().split())
a=sorted(a)[::-1]
A=0
B=0
for i in range(len(a)):
    if i%2==0:
        A+=a[i]
    else:
        B+=a[i]
print(A-B)


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

# Example run
# Input:
-5
-131587518
# Output:
-131587518
N = int(input())
A = [int(a) for a 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:
-1198338
0
# Output:
0
N = int(input())
a = list(map(int, input().split()))
asort = sorted(a, reverse=True)
A = 0
B = 0
for i in range(N):
    if i % 2 == 0:
        A += asort[i]
    else:
        B += asort[i]

print(A - B)


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


# Example run
# Input:
-168854
-5
# Output:
0
n = int(input())
a = sorted(list(map(int, input().split())))[::-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:
-74270783
2147483647
# Output:
0
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)

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

# 降順ソート
a.sort()
a.reverse()

tmp = int(len(a) / 2 + 0.5) - 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)


# Example run
# Input:
-70037
-1002
# Output:
-1002
n = int(input())
cards = sorted(list(map(int, input().split())), reverse=True)

alice = cards[::2]
bob = cards[1::2]

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

# Example run
# Input:
8131
1813543
# Output:
1813543
N = int(input())
A = [int(s) for s in input().split()]
A.sort(reverse=True)
print(sum(A[0::2]) - sum(A[1::2]))


# Example run
# Input:
-3828
1
# Output:
1
def ret_max(n, list):
    i = 0
    tmp = 0
    max = 0
    for i in range(n):
        if(max < list[i]):
            tmp = i
            max = list[i]
    return tmp

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

j = 0
k = 0
alice = 0
bob = 0
max = 0
lis_elem = len(lis)

for j in range(N):
    lis_elem = len(lis)
    max = lis[ret_max(lis_elem, lis)]
    print("max:",max)
    del lis[ret_max(lis_elem, lis)]
    if(j%2 == 0):
        alice = alice + max
    elif(j%2 == 1):
        bob = bob + max

print(alice - bob)


# Example run
# Input:
-40
-18579092
# Output:
0
N = int(input())
B = list(map(int, input().split()))

one =[]
two =[]
count = 0
if N%2 ==0:
  while count <= N:
    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:
-2
709214891
# Output:
[]
[]
0
N = int(input())
lst = list(map(int, input().split()))
alice = []
bob = []
lst.sort(reverse=True)
for i in range(N):
    if i%2 == 0:
        alice.append(lst[i])
    else:
        bob.append(lst[i])

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

# Example run
# Input:
-97071
36241
# Output:
0
N = int(input())
le = list(map(int, input().split()))

player = [0,0]
turn = 0
count = 0

while(1):
    count+=1
    mx = max(le)
    player[turn]+=mx
    le.remove(mx)
    if count==N:
        break
    if turn==0:
        turn=1
    else:
        turn=0


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


# Example run
# Input:
1
-236387597
# Output:
-236387597
N = int(input())
a = list(map(int, input().split()))
alice_p = 0
bob_p = 0
a.sort(reverse=True)

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

print(alice_p - bob_p)


# Example run
# Input:
-5
-14993
# 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:
-99110661
2
# Output:
2
#入力取得
N = int(input())
a = [int(i) for i in input().split()]

#aを降順にソートする。
a.sort(reverse=True)

a_sum = 0
b_sum = 0

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

    elif i % 2 == 1:
        b_sum = b_sum + a[i]


print(a_sum - b_sum )

# Example run
# Input:
1418198351
9
# Output:
9
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)

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


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

a.sort()
a.reverse()

sa = 0
sb = 0

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

print(sa-sb)

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

alist = sorted(alist, reverse=True)
black = sum(alist[::2])
white = sum(alist[1::2])

print(black - white)

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

count = 0
A = 0
B = 0

while count < N+1 and len(a) >0: 
	m = max(a)
	A += m
	a.remove(m)  
	if len(a) > 0:
		m = max(a)
		B += m
		a.remove(m)
	count +=1

print(A - B)

# Example run
# Input:
-6
-1138
# Output:
0
N = int(input())
A = list(map(int,input().split()))
A = sorted(A)
Alice = []
Bob = []
for i in range(N) :
    if i % 2 == 0 :
        Alice.append(A[-1])
    else :
        Bob.append(A[-1])
    A.pop(-1)
print(sum(Alice)-sum(Bob))



# Example run
# Input:
-10492971
61186
# Output:
0
n=int(input())
a=sorted([int(i) for i in input().split()], reverse=True)
print(sum([v for k,v in enumerate(a) if k % 2 == 0]) - sum([v for k,v in enumerate(a) if k % 2 != 0]))



# Example run
# Input:
-58138
-607
# Output:
-607
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:
945
0
# Output:
0
N = int(input())
A = list(map(int, input().split()))

score_a = 0
score_b = 0

while len(A):
	max_i = A.index(max(A))
	score_a += A.pop(max_i)

	if len(A):
		max_i = A.index(max(A))
		score_b += A.pop(max_i)

print(score_a - score_b)


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

a.sort()
a.reverse()

Alice = 0
Bob  = 0

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

print(Alice - Bob)

# Example run
# Input:
-16
-9057988
# Output:
-9057988
n = int(input())
num_list =list(map(int,input().split()))
num_list.sort(reverse=True)
bob = 0
alice = 0
for i,num in enumerate(num_list):
    if i%2 == 0:
        alice += num
    else:
        bob += num
print(alice-bob)

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

a.sort(reverse=True)

alice = True
al = 0
bo = 0

for a_ in a:
    if alice:
        al += a_
    else:
        bo += a_
    alice = not alice

print(al - bo)

# Example run
# Input:
142
-30
# Output:
-30
n = int(input())
a_list = [int(x) for x in input().split()]
alice = bob = 0
for i, a in enumerate(sorted(a_list, reverse=True)):
    if i % 2 == 0:
        alice += a
    else:
        bob += a
print(alice - bob)


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

a.sort(reverse=True)

Alice, Bob = 0, 0
for i in a[::2]:
    Alice += i
    
for i in a[1::2]:
    Bob += i

result = Alice - Bob

print(result)

# Example run
# Input:
411
-981245579
# Output:
-981245579
N = int(input())
card_list = list(map(int, input().split()))
card_list.sort(reverse=True)

alice = 0
bob = 0

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

print(abs(alice - bob))


# Example run
# Input:
298151
-755
# Output:
755
input();a,b,c=0,0,sorted(map(int,input().split()))
while c:
  a+=c.pop()
  b+=c.pop() if c else 0
print(a-b)

# Example run
# Input:
~jR@c!;Q
33
# Output:
33
N = input()

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

list.sort(li,reverse=True)

#print(li)
#print(len(li))
l = 0
g = 0

for i in range(0,(len(li)),2):
    #l =[int(x) for x in list(str(i))]
    l += li[i]
#print(l)


for j in range(1,(len(li)),2):
    #m =[int(y) for y in list(str(j))]
    g += li[j]
#print(g)

print(l-g)




# Example run
# Input:
#("Ua
463887247
# Output:
463887247
N = input().split()
a = list(map(int,input().split()))
a.sort(reverse=True)
Bob = 0
Alice = 0
for i,b in enumerate(a):
    if i % 2 == 0:
        Alice += b
    else:
        Bob += b

print(Alice - Bob)

# Example run
# Input:
{T0
26445607
# Output:
26445607
n = int(input())
a = list(map(int, input().split()))
a.sort()
x = 0
y = 0
for i in range(len(a)):
    b = a.pop()
    if i % 2 == 0:
        x += b
    else:
        y += b
print(x - y)

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

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


# Example run
# Input:
-46
13739
# Output:
13739
#!/usr/bin/env python

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

alice = []
bob = []
a_sorted = sorted(a)
# print(a_sorted)

while len(a_sorted) != 0:
    max = a_sorted.pop()
    # print(max)
    alice.append(max)
    if(len(a_sorted) != 0):
        max = a_sorted.pop()
        bob.append(max)

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


# Example run
# Input:
{t#*\J9
1419428
# Output:
1419428
n=int(input())
card=list(map(int,input().split()))
card.sort(reverse=True)
for i in range(1,n,2):
    card[i]*=(-1)
print(sum(card))

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

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

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


# Example run
# Input:
981571
-6163826
# Output:
-6163826
N = int(input())

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

A.sort(reverse=True)

Alice = 0
Bob = 0

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

print(Alice - Bob)

# Example run
# Input:
-812896393
-97075663
# Output:
-97075663
def bb088():
    n = int(input())
    an = list(map(int, input().split()))
    an.sort()

    a = 0
    b = 0
    for i in range(n-1, -1, -2):
        a += an[i]
        if i-1 >= 0:
            b += an[i-1]

    print(a-b)

bb088()


# Example run
# Input:
-15303
-412794
# Output:
0
N = int(input())
A = list(map(int, input().split()))
alice, bob = 0, 0

for i in range(N):
    m = max(A)
    A.remove(m)
    if i % 2 == 0:
        alice += m
    else:
        bob += m
print(alice - bob)


# Example run
# Input:
-572778325
-6
# Output:
0
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
alice = bob = 0
for n, a in enumerate(A):
    if n % 2:
        bob += a
    else:
        alice += a
print(alice-bob)


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

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

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

a.sort(reverse=True)

alice_score = 0
bob_score = 0

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

print(alice_score - bob_score)


# Example run
# Input:
363865392
-1377730
# Output:
-1377730
n = int(input())
d = [int(i) for i in input().split()]
a = 0
b = 0
d.sort()
for x in range(n):
    if(x%2==0):
        a+=d[n-1-x]
    else:
        b+=d[n-1-x]
print(str(a-b))

# Example run
# Input:
-34
3
# Output:
0
n=int(input())
a = list(map(int,input().split()))[:n]
a.sort(reverse=True)

A=B=I=0
for i in a:
    if I %2:B+=i
    else:A+=i
    I+=1

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


# Example run
# Input:
-3550
-11385106
# Output:
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:
30125521
-1325982
# Output:
-1325982
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)

# Example run
# Input:
141725276
-109089799
# Output:
-109089799
N = int(input())
a = list(map(int, input().split()))
A = 0
B = 0
a = sorted(a)
for i, e in enumerate(a):
    if i % 2 == 0:
        A += e
    else:
        B += e
print(abs(A - B))

# Example run
# Input:
-93026
90
# Output:
90
N = int(input())
a = list(map(int, input().split()))
alice = 0
bob = 0

while True:
    alice += a.pop(a.index(max(a)))
    if len(a) <= 0:
        break
    bob += a.pop(a.index(max(a)))
    if len(a) <= 0:
        break

print(alice-bob)

# Example run
# Input:
16806
72781634
# Output:
72781634
n=input()
l=list(map(int,input().split()))
l.sort(reverse=True)
a=0
for i in l[::2]:
    a+=i
for i in l[1::2]:
    a-=i
print(a)

# Example run
# Input:
VLLU9,h&
-1141
# Output:
-1141
_ = input()
l = list(map(int,input().split()))
l.sort()
l.reverse()
print(sum(l[::2])-sum(l[1::2]))

# Example run
# Input:
[_y3ny`
729767900
# Output:
729767900
N = int(input())
int_list = list(map(int, input().split()))

int_list.sort(reverse=True)
odd = int_list[::2]
even = int_list[1::2]
print(sum(odd)-sum(even))

# Example run
# Input:
-5056872
2072477
# Output:
2072477