Felix6326727/beyond-accuracy-code-comprehension huggingface dataset:
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:
-16476
8
# 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:
-390
16707581
# Output:
16707581
n = int(input())
array = list(map(int, input().split()))

bob = []
alice = []
for i in range(1, n+1):
    max_value = max(array)
    if i % 2 == 1:
        alice.append(max_value)
    else:
        bob.append(max_value)
    array.remove(max_value)

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


# Example run
# Input:
-55649
-7038374
# Output:
0
n = int(input())
cards = [int(i) for i in input().split()]

cards.sort(reverse=True)
a = 0
b = 0
for i in range(n):
    if i % 2 == 0:
        a += cards[i]
    else:
        b += cards[i]
print(a - b)

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

a.sort(reverse=True)

alice = sum([s for idx,s in enumerate(a) if idx%2==0])
bob   = sum([s for idx,s in enumerate(a) if idx%2==1])

print(alice-bob)

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


# Example run
# Input:
139893
5182
# Output:
5182
N = int(input())
a_list = list(map(int, input().split()))
a_list.sort(reverse=True)
Alice = []
Bob = []
for idx, v in enumerate(a_list):
    if idx % 2 == 0:
        Alice.append(v)
    else:
        Bob.append(v)
print(sum(Alice) - sum(Bob))


# Example run
# Input:
1008752943
-37
# Output:
-37
n = int(input())
a = list(map(int,input().split()))
a.sort()

c = a[-2::-2]
d = a[-1::-2]

print(sum(d)-sum(c))

# Example run
# Input:
1
2
# Output:
2
N = int(input())
lis = list(map(int,input().split()))

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

print(A-B)

# Example run
# Input:
-56661351
981571
# Output:
0
N = int(input())
A = list(map(int,input().split()))
Alice = 0
Bob = 0
card = 0
for i in range(N):
    if A == []:
        break
    card = max(A)
    if card == 0:
        break
    else:
        Alice += card
        A.remove(card)
    if A == []:
        break
    card = max(A)
    if card == 0:
        break
    else:
      Bob += card
      A.remove(card)
print(Alice-Bob)

# Example run
# Input:
945
0
# Output:
0
N=int(input())
a=list(map(int, input().split()))
a.sort()
A=0
B=0
is_A=True
while len(a)>0:
  if is_A:
    A+=a.pop()
  else:
    B+=a.pop()
  is_A = not is_A
print(A-B)


# Example run
# Input:
2116
-579377
# Output:
-579377
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)
    else:
        bob += max(A)
    A.remove(max(A))
    
print(alice - bob)

# Example run
# Input:
-53605951
3
# Output:
0
n = int(input())
card_list = list(map(int, input().split()))

alice_point = 0
bob_point = 0

def pick_card(card_list):
    # print(card_list)
    max = 0
    max_index = 0
    for i in range(card_list.__len__()):
        # print('-------', i)
        if card_list[i] > max:
            # print('@', i, ':', max, '<', card_list[i])
            max = card_list[i]
            max_index = i
    
    del card_list[max_index]

    # print('----', card_list)

    return max, card_list

turn = 0
while turn < n:
    # print('--', turn)
    remain_list = []
    if turn % 2 == 0:
        alice_get, remain_list = pick_card(card_list)
        alice_point += alice_get
    else:
        bob_get, remain_list = pick_card(card_list)
        bob_point += bob_get

    card_list = remain_list
    # print(alice_point, bob_point, card_list)

    turn += 1

print(alice_point - bob_point)

# Example run
# Input:
-1
2657144
# Output:
0
n = int(input())
a = list(map(int, input().split()))
sum_a, sum_b = 0, 0

for i in range(n):
    sum_a += max(a)
    a[a.index(max(a))] = 0
    sum_b += max(a)
    a[a.index(max(a))] = 0

print(sum_a - sum_b)

# Example run
# Input:
66169
1294
# Output:
1294
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
alice = []
bob = []
while len(a) >= 1:
    alice.append(a.pop())
    if len(a) >= 1:
        bob.append(a.pop())
print(sum(alice) - sum(bob))

# Example run
# Input:
10366
-5271130
# Output:
-5271130
N = int(input())
cards = list(map(int, input().split()))
cards.sort(reverse = True)
A = 0
B = 0
for i in range(0, N):
  if i%2 == 0:
    A += cards[i]
  else:
    B += cards[i]
print(A-B)

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

A_ = sorted(A, reverse=True)
print(sum(A_[::2]) - sum(A_[1::2]))


# Example run
# Input:
-63
-213058
# Output:
-213058
# -*- coding: utf-8 -*-
a = int(input())  # Nを入力
b = input()  # a1,a2...anを入
b = map(int, b.split())
b = sorted(b)
b = b[::-1]
c = b[::2]
c_number = len(c)
d = b[1::2]
d_number = len(d)
c_sum = 0
d_sum = 0
for i in range(c_number):
    c_sum += c[i]

for g in range(d_number):
    d_sum += d[g]

print(c_sum - d_sum)



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

# Example run
# Input:
LX)g;b8
8030667
# Output:
8030667
a = int(input())
b = sorted(list(map(int, input().split())), reverse=True)

alice = 0
bob = 0

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

print(alice-bob)

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

print(ans)

# Example run
# Input:
-10
453
# Output:
0
N = input()
a = sorted(list(map(int, input().split())), reverse = True )

Al = sum(a[::2])
Bo = sum(a[1::2])

print(Al-Bo)


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

# Example run
# Input:
-134171884
-253690
# Output:
-253690
# -*- coding: utf-8 -*-

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

Alice = 0
Bob = 0

for x in range(0, len(a), 2):
    Alice += a[x]

for x in range(1, len(a), 2):
    Bob += a[x]

print(Alice - Bob)

# Example run
# Input:
8796677
-1595467139
# Output:
-1595467139
# 2020-08-30, Sun

n = int(input())
lis = sorted(list(map(int, input().split())))
a = 0
b = 0

for i in lis[::2]:
    a += i

for i in lis[1::2]:
    b += i

print(b - a)

# Example run
# Input:
-2552
-330190783
# Output:
330190783
n=int(input())
card=list(map(int,input().split()))
A=0
B=0
count=0
while len(card)!=0:
    point=max(card)
    if count%2==0:
        A +=point
    else:
        B +=point
    count +=1
    card.remove(point)
print(A-B)

# Example run
# Input:
805965556
-19
# Output:
-19
N=int(input())
tramp=list(map(int,input().split()))
tramp.sort(reverse=True)
tramp.append(0)
alice=0
bob=0
for i in range(0,N,2):
    alice+=int(tramp[i])
    bob+=int(tramp[i+1])
print(alice-bob)

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

# Example run
# Input:
-802253
-150069
# Output:
-150069
n=int(input())
l=list(map(int,input().split()))
l.sort(reverse=True)
alice,bob=[],[]
for i in range(1,n+1):
    if i%2==1: alice.append(l[i-1])
    elif i%2==0: bob.append(l[i-1])
print(sum(alice)-sum(bob))

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

# Example run
# Input:
-619455
-4
# Output:
0
# ABC 088
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
def db(x): 
    global debug
    if debug: print(x)
debug = False
N = getInt()
a = getIntList()
a.sort()
a.reverse()
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:
-31
-58867430
# Output:
0
N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
print(sum(A[0::2]) - sum(A[1::2]))


# Example run
# Input:
339175880
510778600
# Output:
510778600
N = int(input())
A = list(map(int, input().split()))

A = sorted(A, 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:
58756
-14
# Output:
-14
N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)

Alice = 0
Bob = 0
for i in range(N):
  temp = A.pop(0)
  if i % 2 == 0:
    Alice += temp
  else:
    Bob += temp

print(str(Alice - Bob))

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


# Example run
# Input:
-7038374
-6
# Output:
0
class CardGameforTwo:
    def __init__(self):
        self.alice_card_list = []
        self.alice_count = 0
        self.bob_card_list =[]
        self.bob_count = 0
        self.total_card_num = 0
        self.card_list = []
    
    def get_card(self, total_card_num, card_list):
        card_list.sort(reverse=True)
        card_num = 0
        for c in card_list:
            if card_num % 2 == 0:
                self.alice_card_list.append(c)
            else:
                self.bob_card_list.append(c)
            card_num +=1
        return self.alice_card_list, self.bob_card_list
    
    def count_result(self, a_card_list, b_card_list):
        for a in a_card_list:
            self.alice_count +=a
        for b in b_card_list:
            self.bob_count +=b
        result = self.alice_count - self.bob_count
        return result

if __name__ == '__main__':
    N = input()
    a =list(map(int, input().split()))
    cgt = CardGameforTwo()
    a_card_list, b_card_list=cgt.get_card(N, a)
    result = cgt.count_result(a_card_list, b_card_list)
    print(result)


# Example run
# Input:
$[><G
1008752943
# Output:
1008752943
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
al = 0
bb = 0
for i in range(n):
  if i % 2 == 0:
    al += a[i]
  else:
    bb += a[i]
print(al - bb)

# Example run
# Input:
-114
-473
# Output:
0
n=int(input())
li=list(map(int,input().split()))
li.sort()
a=[]
b=[]
for i in range(n):
  if n%2==1:
    if i%2==0:
      a.append(li[i])
    else:
      b.append(li[i])
  else:
    if i%2==0:
      b.append(li[i])
    else:
      a.append(li[i])
print(sum(a)-sum(b))

# Example run
# Input:
-54
981571
# Output:
0
n = int(input())
an = list(map(int,input().split()))
an_s = sorted(an, reverse=True)
alice = 0
bob =0


for i in range (n):
  if i%2 == 0:
    alice += an_s[i]
  elif i%2 != 0:
    bob += an_s[i]

ans = alice - bob
print(ans)
    

# Example run
# Input:
-15915
-501843
# Output:
0
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse = True)
Alice = []
Bob = []
while len(A) != 0:
        Alice.append(A[0])
        A = A[1:]
        if len(A) != 0:
                Bob.append(A[0])
                A = A[1:]

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

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

# Example run
# Input:
%Exq\|E
2144
# Output:
2144
def ABC088B():    
    n = int(input())
    ai = list(map(int,input().split()))

    # リストを降順にソートする
    ai.sort(reverse=True)
    ans = sum(ai[0::2]) - sum(ai[1::2])

    print(ans)

if __name__ == '__main__' :
    ABC088B()

# Example run
# Input:
-38181262
41286958
# Output:
41286958
n = int(input())
a = list(map(int, input().split()))
alice = []
bob = []
a.sort()
a = a[::-1]
for i in range(n):
    if len(alice) > len(bob):
        bob.append(a[i])
    else:
        alice.append(a[i])
print(sum(alice) - sum(bob))


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

# Example run
# Input:
-224960337
446
# Output:
0
import math

#n, a, b= map(int, input().split())
#a, b  = map(int, input().split())
#h = list(map(int, input().split()))
#s = list(str(input()))
n = int(input())
a = list(map(int, input().split()))

alice = 0
bob   = 0

for i in range(n):
  a.sort(reverse=True)
  alice = alice + a[0]*((i+1)%2)
  bob   = bob   + a[0]*(i%2)
  a[0] = 0
    
print(alice - bob)

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

tmp = []
ttmp = []

list.sort(a,reverse=True)

for i in range(1,n+1):
    if i%2==1:
        tmp.append(a.pop(0))
    if i%2==0:
        ttmp.append(a.pop(0))
        # ttmp = a.pop(0)

print(sum(tmp)-sum(ttmp))

# Example run
# Input:
-264371717
10366
# 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:
-4169
-76577
# Output:
-76577
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:
-41270
-2
# Output:
0
n = int(input())
line = list(map(int, input().split()))
line.sort()
line.reverse()
A = 0
B = 0
for i in range(1,n+1):
  if i % 2 != 0:
    A += line[i-1]
  else:
    B += line[i-1]
print(A-B)

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

a.sort(reverse=True)
b = a[::2]
c = a[1::2]

print(sum(b) - sum(c))

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

# Example run
# Input:
-22588477
11
# Output:
11
if __name__ == '__main__':
    n = int(input())
    k = [int(i) for i in input().split()]
    a = 0
    b = 0
    k.sort(reverse=True)
    print(k)
    flag = True
    for i in k:
        if flag == True:
            a+=i
            flag=False
        else:
            b+=i
            flag=True
    print(a-b)


# Example run
# Input:
-187845
-17367
# Output:
[-17367]
-17367
N = int(input())
a = list(map(int,input().split()))
b = sorted(a, reverse=True) 
Alice = 0
Bob = 0

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



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

# Example run
# Input:
ddELChMh
-1198338
# Output:
-1198338
# -*- coding: utf-8 -*-

n = int(input())
a = list(map(int,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:
-6
-420
# Output:
0
if __name__ == '__main__':
    N = int(input())
    A = [None]*N
    A = list(map(int, input().split()))
    Alice = 0
    Bob = 0
    while(A):
        Alice += max(A)
        A.remove(max(A))
        if A:
            Bob += max(A)
            A.remove(max(A))
    print(Alice - Bob)

# Example run
# Input:
3478382
-2773
# Output:
-2773
n = int(input())
dat_a = list(map(int, input().split()))
dat_a.sort()
a = 0
b = 0
while True:
    if len(dat_a) ==0:
        break
    a += dat_a.pop()

    if len(dat_a) ==0:
        break
    b += dat_a.pop()
print(a-b)

# Example run
# Input:
-14665841
-235202
# Output:
-235202
N = int(input())
A = list(map(int, input().split()))

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


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

# Example run
# Input:
224
-3753932
# Output:
-3753932
def main():
    n = int(input())
    a = list(map(int, input().split()))
    m = 0
    y = 0
    sort_a = sorted(a, reverse=True)
    for i in range(n):
        if i % 2 == 0:
            m += sort_a[i]
        else:
            y += sort_a[i]
    print(m - y)
main()


# Example run
# Input:
-21
-687
# Output:
0
n = int(input())
a,b = 0,0
cards = [int(val) for val in input().split()]
 
cards = sorted(cards, reverse=True)
 
for i in range(n):
    if i % 2 == 0:
        a += cards[i]
    else:
        b += cards[i]
        
print(a - b)

# Example run
# Input:
-58
-282811832
# Output:
0
N = int(input())
a = [0]*N
a = list(map(int, input().split()))
a.sort()
a_sort = [i for i in a[::-1]]
Alice = [i for i in a_sort[::2]]
Bob = [i for i in a_sort[1::2]]
print(sum(Alice)-sum(Bob))

# Example run
# Input:
-22
-2334
# Output:
-2334
def draw_max_card(card_list):
    max_card = max(card_list)
    card_list.remove(max_card)
    return max_card

n = int(input())
card_list = list(map(int, input().split(" ")))
points_alice = 0
points_bob  = 0
for count in range(1, n + 1):
    print(count)
    if count % 2 != 0:
        points_alice += draw_max_card(card_list)
    else:
        points_bob += draw_max_card(card_list)


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

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

# Example run
# Input:
8vLAk
-158606
# Output:
-158606
n=int(input())
x=list(map(int,input().split()))
a=0
b=0
for i in range(n//2):
  a+=max(x)
  x.remove(max(x))
  b+=max(x)
  x.remove(max(x))

if n%2:
  a+=x[0]
dif=a-b
print(dif)

# Example run
# Input:
-104837
-69520
# Output:
-69520
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
bob=sum([a[i] for i in range(n) if i%2==1])
al=sum([a[i] for i in range(n) if i%2==0])
print(al-bob)

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

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

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

# Example run
# Input:
-820
1033
# 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:
-15860207
-54634663
# Output:
-54634663
# coding: UTF-8
#@document_it
from collections import deque
def document_it(func):
    def new_function(*args,**kwargs):
        print('Running function:', func.__name__)
        print('Positional arguments:', args)
        print('Kewword arguments:', kwargs)
        result = func(*args,**kwargs)
        print('Result:', result)
        return result
    return new_function


def exe():
    N = int(input())
    A = list(map(int,input().split()))
    A.sort()
    s = deque(A)
    alice =0
    bob = 0
    for i in range(N):
        if i % 2 == 0:
            alice += s.pop()
        else:
            bob += s.pop()
    print(alice-bob)

if __name__ == '__main__':
    exe()

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

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

# Example run
# Input:
13087
-31
# Output:
-31
N=int(input())
l=sorted(map(int,input().split()))[::-1]
v=sum([l[i] for i in range(0,N,2)])-sum([l[i] for i in range(1,N,2)])
print(v)

# Example run
# Input:
-150069
470
# Output:
0
import math
n = int(input())
a_list = sorted(list(map(int,input().split())),reverse=True)
alice = []
bob = []
for _ in range(math.ceil(len(a_list)/2)):
    alice.append(a_list.pop(0))
    if len(a_list) == 0:
        break
    bob.append(a_list.pop(0))
print(sum(alice)-sum(bob))

# Example run
# Input:
-491914923
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:
-15015728
42339391
# Output:
42339391
n=int(input())
a=list()
for x in input().split():
    a.append(x)
s=0
t=0

if n%2==0:
    c=0
    while c<n/2:
        x=max(a)
        s=s+int(x)
        a.remove(x)
        y=max(a)
        t=t+int(y)
        a.remove(y)
        c=c+1
else:
    c=0
    l=(n-1)/2
    while c<l:
        x=max(a)
        s=s+int(x)
        a.remove(x)
        y=max(a)
        t=t+int(y)
        a.remove(y)
        c=c+1
    s=s+int(a[0])
print(s-t)

# Example run
# Input:
-4664
26550845
# Output:
0
N = int(input())
As = [int(n) for n in input().split()]

Alice = []
Bob = []

while len(As):
    ma = max(As)
    Alice.append(ma)
    As.remove(ma)
    if len(As):
        mb = max(As)
        Bob.append(mb)
        As.remove(mb)

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


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


# Example run
# Input:
e3zvshd]
45580
# Output:
45580
N = int(input())
cards = sorted(list(map(int, input().split())))

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

print(alice-bob)

# Example run
# Input:
-9486
-1394868732
# Output:
0
n = int(input())
x = list(map(int, input().split()))

x.sort()
x.reverse()

A = []
B = []
for i in range(len(x)):
  if i%2==0:
    m = max(x)
    A.append(m)
    x.remove(m)
  else:
    m = max(x)
    B.append(m)
    x.remove(m)

C = sum(A) - sum(B)
print(C)

# Example run
# Input:
4026
1449827559
# Output:
1449827559
n=int(input())
a=list(map(int, input().split()))
a.sort()
a.reverse()
b=a[0:n:2]
c=a[1:n:2]

print(sum(b)-sum(c))

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

print(sum([a*(-1)**i for i, a in enumerate(A)]))

# Example run
# Input:
1510792572
-224960337
# Output:
-224960337
N = int(input())
lst = list(map(int, input().split()))
lst.sort(reverse = True)
A = 0
B = 0


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

print(A - B)
        

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


# Example run
# Input:
-39645188
-202
# Output:
202
N = int(input())
a = list( sorted(map( int, input().split())))[::-1]
A_B = 0
B = 1

for i in a:
	A_B += i * B 
	B *= -1
    
print(A_B)


# Example run
# Input:
-80
-7517
# Output:
-7517
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
alice=0
bob=0
for i,item in enumerate(a):
  if i%2==0:
    alice+=item
  else:
    bob+=item
print(alice-bob)

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

# Example run
# Input:
-3433
415326
# Output:
0
x = input()
y = list(map(int,input().split()))
a = 0
b = 0
for i, yi in enumerate(sorted(y, reverse=True)):
  if i%2 == 0:
    a += yi
  else:
    b += yi
print(a-b)

# Example run
# Input:
mzP
-842467
# Output:
-842467
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:
1270
248197
# Output:
248197
input()
A = list(map(int, input().split()))
A.sort(reverse=True)

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

print(alice-bob)


# Example run
# Input:
WPR~c
1044
# Output:
1044