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

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

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

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

print(ans)


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

# Example run
# Input:
-579377
# Output:
-579377
n = int(input())
a = list(map(int, input().split()))
a.sort()
x = y = 0
for i, j in enumerate(a):
    if i%2 == 0:
        x += j
    else:
        y += j
print(x - y)

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



# Example run
# Input:
4345
-8164991
# Output:
-8164991
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:
-97071
36241
# Output:
0
n = int(input())

a = sorted(map(int, input().split()), reverse=True)

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

# Example run
# Input:
1049999
4
# Output:
4
n = int(input())
a = [int(an) for an in input().split()]
ans = a[0]
if n > 1:
  a.sort(reverse=True)
  ans = sum(a[::2]) - sum(a[1::2])
print(ans)

# Example run
# Input:
52108041
-38
# Output:
-38
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
A.reverse()
Bob,Alice = 0,0
for i in range(0,N,2):
    Alice += A[i]
    if i+1 < N:
        Bob += A[i+1]
print(Alice - Bob)

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

# Example run
# Input:
1
-513425
# Output:
-513425
if __name__ == '__main__':
    n = int(input())
    a_list = sorted([int(a) for a in input().split()], reverse=True)

    alice_point = sum(a_list[::2])
    bob_point = sum(a_list[1::2])
    print(alice_point - bob_point)

# Example run
# Input:
4345
-8164991
# Output:
-8164991
n=int(input())
a=list(map(int,input().split()))
""" 
print(a) """

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:
-156960
-16
# Output:
0
N = int(input())
cards_number = input()
numbers = list(map(int, cards_number.split()))
ordered_numbers = sorted(numbers, reverse=True)

even_indexes = list(num for num in range(0, N) if num % 2 == 0)
odd_indexes = list(num for num in range(0, N) if num % 2 == 1)
alice_cards = list(ordered_numbers[even_index] for even_index in even_indexes)
bob_cards = list(ordered_numbers[odd_index] for odd_index in odd_indexes)

alice_point = sum(alice_cards)
bob_point = sum(bob_cards)

print(alice_point-bob_point)


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


# Example run
# Input:
471
14
# Output:
14
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)

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

print(Alice-Bob)

# Example run
# Input:
-69520
-73864104
# Output:
0
n = input()
a_list = [int(num) for num in input().split()]

alice = 0
bob = 0

while True:
  if len(a_list) < 1:
    break
  next_num = max(a_list)
  alice += next_num
  a_list.remove(next_num)
  if len(a_list) < 1:
    break
  next_num = max(a_list)
  bob += next_num
  a_list.remove(next_num)

print(alice - bob)

# Example run
# Input:
R&e8
-24296024
# Output:
-24296024
input()
s=[0,0]
t=0
for c in sorted(map(int,input().split()),reverse=True):
  s[t]+=c
  t=not t
print(s[0]-s[1])

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

# Example run
# Input:
-48
465
# Output:
465
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
  else:
    bob += a

print(alice - bob)


# Example run
# Input:
-213058
-83
# Output:
-83
N = int(input())
A = list(map(int, input().split()))
B = sorted(A, reverse=True)
a = 0
b = 0
for i in range(0, N, 2):
  a += B[i]
for j in range(1, N, 2):
  b += B[j]
print(a - b)

# Example run
# Input:
-75
57223618
# Output:
0
n = int(input())
cards = sorted(map(int, input().split()), reverse=True)
score_alice, score_bob = 0, 0

for i in range(n):
  if i % 2 == 0:
    score_alice += cards[i]
  else:
    score_bob += cards[i]

print(score_alice - score_bob)



# Example run
# Input:
-1794
-1147387
# Output:
0
n=int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
p=0
q=0

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

# Example run
# Input:
-14968
-2585113
# Output:
0
### coding: UTF-8
 
#import math
#import random as rd
#import numpy as np
 
 
n=int(input())
line=list(map(int,input().split( )))
 
line=sorted(line)
 
#print(line)
 
s=sum([line[-(i+1)] for i in range(n) if i%2==0])-sum([line[-(i+1)] for i in range(n) if i%2!=0])
 
print(s)
 

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

# Example run
# Input:
-7
7715
# Output:
0
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
c1 = 0
c2 = 0
for i in a[::2]:
    c1 += i
    a.remove(i)
c2 = sum(a)
print(c1 - c2)

# Example run
# Input:
0
-14125092
# Output:
-14125092
n=int(input())
a=list(map(int,input().split()))
a=sorted(a,reverse=True)
alice=0
bob=0
for i in range(0,n,2):
    alice=alice+a[i]
for j in range(1,n,2):
    bob=bob+a[j]
print(alice-bob)

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

# Example run
# Input:
-558
15964
# Output:
0
n=int(input())
l=list(map(int,input().split(" ")))
i=0
a=0
b=0

while len(l)!=0:
    if i%2==0:
        a+=max(l)
        l.remove(max(l))
    else:
        b+=max(l)
        l.remove(max(l))
    i+=1
print(a-b)

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

# Example run
# Input:
X_C
1169288485
# Output:
1169288485
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:
-56834839
1288
# Output:
1288
#!/usr/bin/env python3
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)

al = 0
bo = 0

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

print(al - bo)


# Example run
# Input:
1
4887419
# Output:
4887419
N = int(input())
a = list(map(int, input().split()))
Alice = 0
Bob = 0
for i in range(N):
  if (i+1)%2 == 1:
    Alice += max(a)
    a.remove(max(a))
  else:
    bob += max(a)
    a.remove(ma(a))
print(Alice - Bob)

# Example run
# Input:
-2
1973033
# Output:
0
def solve1(n, lst):
    alice, bob = 0, 0

    #print(" i |a[i]|Alice|Bob")
    # print("------------------")

    for i in range(n):
        if i % 2 == 0:
            alice += lst[i]
        else:
            bob += lst[i]
        # print(f"{i:3d}|{a[i]:3d}|{alice:5d}|{bob:5d}")

    return alice - bob


n = int(input())
a = list(map(int, input().split(" ")))
a.sort(reverse=True)
print(solve1(n, a))


# Example run
# Input:
-31
-58867430
# 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:
40638
375
# Output:
375
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:
-39
2569
# Output:
0
# coding: utf-8

n = int(input())

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

a,b = 0,0

for i in range(n):
    if i%2==0:
        a += max(card)
        card.pop(card.index(max(card)))
    else:
        b += max(card)
        card.pop(card.index(max(card)))
        
    
print(a-b)

# Example run
# Input:
-331
18
# Output:
0
N = int(input())
As = list(map(int, input().split()))

As.sort(reverse=True)

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


# Example run
# Input:
-15220
71127
# Output:
71127
n = int(input())
a_list = sorted([int(s) for s in input().split()], reverse=True)
sum_list = [0, 0]
for i in range(n):
    sum_list[i % 2] += a_list[i]
print(sum_list[0] - sum_list[1])

# Example run
# Input:
-14
0
# Output:
0
N = int(input())
cards = [int(i) for i in input().split()]
cards.sort(reverse=True)

diff = 0

for idx, i in enumerate(cards):
	if idx % 2 == 0:
		diff += i
	else:
		diff -= i

print(diff)

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

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


# Example run
# Input:
-133790981
215616622
# Output:
0
N=int(input())
ai=list(map(int,input().split()))
ai.sort()
ai.reverse()
al=0
bob=0
for i in range(0,N,2):
    al+=ai[i]
for i in range(1,N,2):
    bob+=ai[i]
print(al-bob)

# Example run
# Input:
-640183291
155287
# Output:
0
def main():
    n = int(input())
    As = sorted(list(map(int, input().split())))[::-1]

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

    ans = alice - bob
    print(ans)


if __name__ == "__main__":
    main()


# Example run
# Input:
-12503953
-345658
# Output:
0
num = int(input())
alist = input().split(" ")
alist = list(map(int,alist))

def max_number(l):
    sum = max(l)
    l.remove(sum)
    return sum

def alice_bob(n,m):
    q = 0
    a = 0
    b = 0
    while q <= n-1:
        temp = max_number(m)
        a += temp
        temp = 0
        q += 1
        if q <= n-1:
            temp = max_number(m)
            b += temp
            temp = 0
            q += 1
    sub = a-b
    return sub

ans = alice_bob(num,alist)
print(ans)

# Example run
# Input:
-887384
13499019
# Output:
0
N = int(input())
card_list = list(map(int,input().split()))
sorted_list = sorted(card_list,reverse=True)
Alice_score = sum(sorted_list[0::2])
Bob_score =  sum(sorted_list[1::2])
print(Alice_score-Bob_score)

# Example run
# Input:
-436344399
-83
# Output:
-83
N = int(input())
a_s = list(map(int, input().split()))

a_s = sorted(a_s)

alice = 0
bob = 0
for i in range(N):
    if i % 2 == 0:
        alice += a_s.pop()
    else:
        bob += a_s.pop()

print(alice-bob)


# Example run
# Input:
0
339009547
# Output:
0
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
A = nl()

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:
-163
4554
# Output:
0
n=int(input())
li=map(int,input().split())
li=sorted(li)
A=0
B=0
for k in range(n//2):
  A += li[2*k]
  B += li[2*k+1]
if n % 2 ==1:
  A += li[n-1]
print(B-A)


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

print(A-B)

# Example run
# Input:
-254646
-247
# Output:
247
n=int(input())
a=sorted([int(i) for i in input().split()])
alice=0
bob=0
for i in range(n):
    if i%2==0:
        alice+=a.pop()
    else:
        bob+=a.pop()
print(alice-bob)

# Example run
# Input:
-5930
-31
# Output:
0
N = int(input())
A = list(map(int, input().split()))
A_ = sorted(A, reverse=True)

Ans = 0
flag = True
for i in A_:
    if flag:
        Ans += i
        flag = False
    else:
        Ans -= i
        flag = True
print(Ans)



# Example run
# Input:
5228
-2059433
# Output:
-2059433
N = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
count = 1
A = []
B = []
for a in l:
    if count % 2 == 1:
        A.append(a)
    else:
        B.append(a)
    count += 1
print(sum(A) - sum(B))


# Example run
# Input:
-31
224
# Output:
224
input()
A = list(map(int, input().split()))

A.sort(reverse=True)
print(sum([A[i] for i in range(len(A)) if i % 2 == 0]) - sum([A[i] for i in range(len(A)) if i % 2 == 1]))

# Example run
# Input:
M/X&w)
0
# Output:
0
n = int(input())
card = list(map(int,input().split()))

a = 0
b = 0

card.sort(reverse=True)

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

# Example run
# Input:
-10006
-3329726
# Output:
0
def main():
    N = int(input())
    l = [int(x) for x in input().split()]
    Alice = 0
    Bob = 0
    l.sort()
    l.reverse()
    for i in range(len(l)):
        if i % 2 == 0:
            Alice += l[i]
        else:
            Bob += l[i]
    print(Alice-Bob)
main()

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

# Example run
# Input:
2147483647
71
# Output:
71
N=int(input())

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

b.sort(reverse=True)

alice=[]
bob=[]

for i in range(N):
    if i==0:
        alice.append(b[i])
    elif i%2==0:
        alice.append(b[i])
    else :
        bob.append(b[i])

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

# Example run
# Input:
-227348
-29
# Output:
0
N = int(input())
a = sorted(map(int, input().split()))

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

# Example run
# Input:
298151
-755
# Output:
755
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:
-2314351
3986
# Output:
0
alice = 0
bob = 0
n = int(input())

a = sorted(list(map(int, input().split(' '))), reverse=True)
for i in a[::2]: alice += i
for i in a[1::2]: bob += i

print(alice - bob)


# Example run
# Input:
-75
57223618
# Output:
57223618
N = int(input())
card_num = list(map(int, input().split()) )
card_num.sort(reverse=True)

alice = 0
bob = 0

for i in range(0,N):
  if i %2 == 0:
    alice += card_num[i]
  else:
    bob   += card_num[i+1] 
ans = int(alice - bob)

print(ans)

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

# Example run
# Input:
0
-27
# Output:
-27
n = int(input())
alice = 0
bob = 0
cards = [int(val) for val in input().split()]

cards = sorted(cards, reverse=True)

print(cards)

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

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

# Example run
# Input:
25086089
1
# Output:
1
# ABC088B - Card Game for Two
n = int(input())
lst = sorted(list(map(int, input().rstrip().split())), reverse=True)
total = 0
for i in range(n):
    if i % 2 == 0:
        total += lst[i]
    else:
        total -= lst[i]
print(total)

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

print(diff)

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

# Example run
# Input:
-54634663
3615919
# Output:
3615919
I=input
N,A=I(),list(map(int,I().split()))
A.sort()
print(sum(A[-1::-2])-sum(A[-2::-2]))

# Example run
# Input:
@`(RsV.z
0
# Output:
0
N = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
A = 0
B = 0
for i in range(0, N, 2):
    A += a[i]
for i in range(1, N, 2):
    B += a[i]
print(A - B)


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

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

al = 0
bo = 0
print(tmp)
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:
3"Fn!
34675473
# Output:
[34675473]
34675473
input()
a=sorted(list(map(int,input().split())))[::-1]
print(sum(a[::2])-sum(a[1::2]))

# Example run
# Input:
="/;pWdh
1699484121
# Output:
1699484121
n = int(input())
a = list(map(int, input().split()))
a.sort()
alice = 0
for i in range((n - 1) // 2 + 1):
    alice += a[- (2 * i + 1)]
print(2 * alice - sum(a))

# Example run
# Input:
0
15473
# Output:
-15473
from heapq import heapify, heappop
def main():
    card_num = int(input())
    cards = list(map(lambda x: -int(x), input().split()))
    heapify(cards)

    A_score = 0
    B_score = 0
    As_turn = True

    for i in range(card_num):
        card = - heappop(cards)
        if As_turn:
            A_score += card
        else:
            B_score += card
        As_turn = not As_turn

    diff = A_score - B_score
    print(diff)

main()

# Example run
# Input:
-13902095
-168
# Output:
0
N=int(input())
# print(N)

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

A=0
B=0

for i in range(N):
    if i%2==0:
        A+=max(card_list)
        card_list.remove(max(card_list))
        # print(card_list)
    else:
        B+=max(card_list)
        card_list.remove(max(card_list))
        # print(card_list)

# print(A)
# print(B)

print(A-B)

# Example run
# Input:
0
-54266464
# Output:
0
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:
-69520
-73864104
# Output:
0
# 2020-08-30, Sun

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

# Example run
# Input:
-14125092
58756
# Output:
58756
N = int(input())
a = sorted(map(int, input().split()), reverse=True)
sumA = 0
for x in range(len(a)):

    if x % 2 == 0:
        sumA += a[x]
    else:
        sumA -= a[x]
print(sumA)


# Example run
# Input:
5831819
-812896393
# Output:
-812896393
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:
4159
9088477
# Output:
9088477
n = int(input())
a = list(map(int,input().split()))
alice = 0
bob = 0
alice_flag = True

for i in range(n):
    if(alice_flag):
        alice += max(a)
    else:
        bob += max(a)
    a[a.index(max(a))] = 0
    alice_flag = not(alice_flag)

print(alice-bob)


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


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

a.sort()
alice = []
bob = []
for i in range(N):
    if i%2 == 0:
        alice.append(a.pop())
    else:
        bob.append(a.pop())

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

# Example run
# Input:
-959568
-377
# Output:
0
n = int(input())
cardList = list(map(int,input().split()))
a = 0
b = 0
cardList.sort(reverse=True)
while len(cardList) > 0:
    if len(cardList) > 0:
        a += cardList.pop(0)
    if len(cardList) > 0:
        b += cardList.pop(0)
print(a-b)

# Example run
# Input:
15
-24166826
# Output:
-24166826
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:
-1
719497470
# Output:
0
# 整数の入力
n = input()
n = int(n)

# いくつあるかわからないときのスペース区切りの整数の入力
nums = input().split()
nums = list(map(int,nums))

#print(nums)

nums.sort(reverse=True)

#print(nums)

i = 0
Alis = 0
Bob = 0

for i in range(0,n):
    if i % 2 == 0:
        Alis = Alis + nums[i]
    else:
        Bob = Bob + nums[i]

print(Alis-Bob)

#print(Alis)
#print(Bob)


# Example run
# Input:
-1147387
165350
# 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]
print(Alice - Bob)

# Example run
# Input:
-86
11
# Output:
0
N = input()
a = [ int(n) for n in input().split()]
a.sort(reverse=True)
A = B = 0
while len(a) > 0:
	A += a.pop(0)
	if len(a) < 1:
		break
	else:
		B += a.pop(0)
print(str(A-B))

# Example run
# Input:
aA$[><Gb
15761764
# Output:
15761764
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
print(a)
alice = 0
bob = 0
for i in range(0, N):
    if i%2 == 0:
        alice += a[i]
    else:
        bob += a[i]

print(alice - bob)


# Example run
# Input:
-124978655
-23909
# Output:
[-23909]
0
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
al = 0
bo = 0
for i, v in enumerate(a):
    if i % 2 == 0:
        al += v
    else:
        bo += v
print(abs(al - bo))


# Example run
# Input:
-3
-23909
# Output:
23909
n = int(input())
card = list(map(int,input().split()))

card.sort()

ans = 0
for i in range(n//2+1):
            ans += card[2*i]-card[2*i+1]
if n%2==1:
            ans += card[-1]

print(ans)

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

# Example run
# Input:
2653902
-5271130
# Output:
-5271130
size = int(input())
nums = list(map(int, input().split()))
nums.sort()
nums.reverse()

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

# Example run
# Input:
-18771736
12
# Output:
12
n = int(input())
a = list(map(int, input().split()))
count = 0
alice = 0
bob = 0
a.sort()
f = 0
while(len(a) != 0):
    if f == 0:
        alice = alice + a.pop(-1)
        f = 1
    else:
        bob = bob + a.pop(-1)
        f = 0
print(alice - bob)


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

alice_sum = 0
bob_sum = 0
for i in range(n):
  if i% 2 == 0:
    alice_sum += l[i]
  else:
    bob_sum += l[i]

print(alice_sum - bob_sum)

# Example run
# Input:
-8886
-7148954
# Output:
0
N = int(input())
List = list(map(int, input().split()))
List.sort(reverse=True)
A = 0
B = 0
for i in range(N):
  if i % 2 ==0:
    A += List.pop(0)
  else:
    B += List.pop(0)
print(A-B)

# Example run
# Input:
-5701370
-3339504
# Output:
0
#!/usr/bin/env python3
import sys

def main():
    N = int(input())
    a = list(map(int,input().split()))
    b = sorted(a, reverse=True) # aを大きい順に並べる
    
    Alice = 0
    Bob = 0


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


if __name__ == '__main__':
    main()


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

# Example run
# Input:
51
13
# Output:
13
N = int(input())
a = list(map(int, input().split()))
 
# ソートしたとき、Aliceは偶数(0,2,...)番目を、Bobは偶数(1,3,...)番目を取る
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:
-1
-3439167
# Output:
0
n = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
alice = []
bob = []
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:
-29
-5363
# Output:
0