Felix6326727/beyond-accuracy-code-comprehension huggingface dataset:
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("{}".format(Alice-Bob))


# Example run
# Input:
0
11
# Output:
11
N=int(input())
A=list(map(int, input().split()))
sortedA=sorted(A, reverse=True)
Bob=0
Alice=0
for i in range(len(A)):
  # print(i)
  if i == 0 or i%2==0:
    Alice+=sortedA[i]
  else:
    Bob +=sortedA[i]
print(Alice-Bob)


# Example run
# Input:
-58743
-207
# Output:
-207
n=input()
aa=list(map(int,input().split()))
aa.sort(reverse=True)

ab=[0]*2

i=0
for a in aa:
  ab[i%2]+=a
  i+=1

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



# Example run
# Input:
wWCpNZdu
2423
# Output:
2423
Alice = 0
Bob = 0
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:
260615611
20794
# Output:
20794
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:
-274078593
-28418
# Output:
0
# 入力 : 横並びの数字N個（リスト内包表記で）
N = int(input())
list_a = [int(x) for x in input().split()]

# 大きい順にソートして、交互にとったときの差
list_a.sort(reverse = True)

Alice = 0
Bob = 0

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

print(Alice-Bob)


# Example run
# Input:
137752
-5930
# Output:
-5930
# coding-utf8 #

n = int(input())
num_list = list(map(int, input().split()))

alice_sum = 0
bob_sum = 0

num_list.sort(reverse=True)

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

print(alice_sum - bob_sum)

# Example run
# Input:
-168854
-5
# Output:
0
n = int(input())
a_list = sorted(list(map(int, input().split())), reverse=True)
n_alice = sum(a_list[::2])
n_bob = sum(a_list[1::2])
print(n_alice - n_bob)


# Example run
# Input:
-1
-3439167
# Output:
-3439167
n=int(input())
alice=[]
bob=[]
l=list(map(int,input().split()))
while len(l)>0:
    alice.append(max(l))
    l.remove(max(l))
    if len(l)>0:
        bob.append(max(l))
        l.remove(max(l))

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


# Example run
# Input:
-3766
9062461
# Output:
9062461
n = int(input())
a = list(map(int, input().split(' ')))

ali = 0
bo = 0

while len(a) > 0:
    ali += a.pop(a.index(max(a)))
    if len(a) == 0:
        break
    bo += a.pop(a.index(max(a)))

print(ali - bo)


# Example run
# Input:
-55564347
103913001
# Output:
103913001
def main():
    n = int(input())
    a = list((map(int, input().split())))
    a.sort()
    m = 0
    y = 0
    for i in reversed(range(n)):
        if len(a) % 2 == 0:
            if i % 2 != 0:
                m += a[i]
            else:
                y += a[i]
        else:
            if i % 2 == 0:
                m += a[i]
            else:
                y += a[i]
    print(m - y)
main()


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

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

# Example run
# Input:
15
-24166826
# Output:
-24166826
import math
def py():
    print("Yes")
def pn():
    print("No")
def iin():
    x = int(input())
    return x

neko = 0
nya = 0
nuko = 0
a = 0
b = 0
n = iin()
x = [int(x) for x in input().split()]
x.sort(reverse=True)
for i in range(n):
    if i%2 :
        a = a + x[i]
    else:
        b = b + x[i]
print(b-a)

# Example run
# Input:
-75
57223618
# Output:
0
N = int(input())

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

s2 = sorted(s, reverse=True)

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

# Example run
# Input:
-97071
36241
# Output:
36241
# coding: utf-8
# Your code here!

num = int(input())
s = sorted(list(map(int,input().split())) ,reverse=True)
#print(s)

alice,bob = 0,0
for i,j in enumerate(s):
    if i % 2 == 0:
        alice += j
    else:
        bob += j
        
print(alice - bob)
        
    

# Example run
# Input:
-274078593
-28418
# Output:
-28418
n=input()
card=list(map(int, input().split()))
card.sort(reverse=True)
#print(card)
sum=0
turn=0
for i in card:
	if turn ==0:
		sum += i
		turn = 1
	else:
		sum -= i
		turn =0
print(sum)

# Example run
# Input:
+CP)0CA
43251559
# Output:
43251559
n = int(input())
s = sorted(list(map(int,input().split())))[::-1]

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

# Example run
# Input:
-1622400
-55564347
# Output:
-55564347
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:
-84521052
-2
# Output:
0
def bSort(a):
    for i in range(len(a)):
        for j in range(len(a)-1, i, -1):
            if a[j] > a[j-1]:
                a[j], a[j-1] = a[j-1], a[j]

    return a

n = int(input())
list = [int(i) for i in input().split()]

d = bSort(list)


A = 0
B = 0

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

# Example run
# Input:
-1131247330
-9
# Output:
0
N=int(input())
A=input()

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

A_int_list.sort()
A_int_list.reverse()

alice=0
bob=0

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

print(alice-bob)

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

# Example run
# Input:
3478382
-2773
# Output:
-2773
input()
listofCardNo = sorted(list(map(int, input().split())))[::-1]
ans = sum(listofCardNo[0::2]) - sum(listofCardNo[1::2])
print(ans)


# Example run
# Input:
(:s!syT!
0
# Output:
0
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
num = len(a)
alice = []
bob = []
coun = 1
for i in a:
    if coun % 2 == 1:
        alice.append(i)
    else:
        bob.append(i)
    coun += 1
ans = abs(sum(alice) - sum(bob))
print(ans)

# Example run
# Input:
10366
-5271130
# Output:
5271130
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:
-7737
-126905272
# Output:
-126905272
n = int(input())
a = list(map(int, input().split(" ")))
a.sort(reverse = True)
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:
-18231
54
# Output:
0
N = int(input())
A = list(map(int, input().split()))

A_sort = sorted(A, reverse=True)
Alice = [a for i, a in enumerate(A_sort) if i%2==0]
Bob = [a for i, a in enumerate(A_sort) if i%2==1]

ans = sum(Alice) - sum(Bob)

print(ans)

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

card.sort()

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

print(asum-bsum)

# Example run
# Input:
-31
-58867430
# Output:
0
def main():
    N=int(input())
    a=list(map(int,input().strip().split()))
    
    a.sort(reverse=True)
    
    alice=sum(a[n] for n in range(N) if n%2==0)
    bob=sum(a[n] for n in range(N) if n%2==1)
    return alice-bob

if __name__=="__main__":
    print(main())

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

# Example run
# Input:
-1377730
25086089
# Output:
0
N = int(input())
a = list(map(int,input().split()))
a.sort()
a_decending = a[::-1]
Alice = 0
Bob = 0

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


# Example run
# Input:
1
3770
# Output:
3770
N = 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
    elif i%2 == 1:
        Bob += a
answer = Alice - Bob
print(answer)

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

if N == 1:
	print(A[0])
else:
	Alice = sum(A[0::2])
	Bob = sum(A[1::2])
	print(Alice-Bob)

# Example run
# Input:
133233772
1813543
# Output:
1813543
# -*- coding: utf-8 -*-
# ABC 083 B - Some Sums
# 整数の入力
a = int(input())
# スペース区切りの整数の入力
b = [int(s) for s in input().split()]
b.sort(reverse=True)
alice = sum(b[0::2])
bob   = sum(b[1::2])
# print("Alice : {}".format(alice))
# print("Bob   : {}".format(bob))
print(alice - bob)

# Example run
# Input:
0
1418198351
# Output:
1418198351
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:
471619987
-3753932
# Output:
-3753932
n=int(input())
a=list(map(int,input().split()))

a.sort()
a.reverse()
count=0
for i in range(n):
  count+=a[i]*(-1)**i
print(count)

# Example run
# Input:
-407
0
# Output:
0
S = 0
N = int(input())
a = [int(i) for i in input().split()]
a.sort()
for i in range(N):
  S += a[::-1][i] * (-1) ** i
print(S)

# Example run
# Input:
-109089799
-74270783
# Output:
0
N = int(input())
alist = input().split()
aint = list(map(int, alist))
aint = sorted(aint, reverse=True)
count = 1
alice = 0
bob = 0

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

# Example run
# Input:
3208074
49394697
# Output:
49394697
N = int(input())
A = list(map(int, input().split(' ')))
A.sort(reverse=True)

dif = 0
sgn = '+'
for a in A:
    if sgn == '+':
        sgn = '-'
        dif += a
    else:
        sgn = '+'
        dif -= a

print(dif)

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

# Example run
# Input:
559
31946
# Output:
31946
n = input()
cards = list(map(int, input().split()))
sorted_cards = sorted(cards, reverse=True)
alice, bob = [], []
for index, card in enumerate(sorted_cards):
    if index % 2 == 0:
        alice.append(card)
    else:
        bob.append(card)
print(sum(alice) - sum(bob))

# Example run
# Input:
tJ)MTn
-3188281
# Output:
-3188281
N=input()
a=list(map(int,input().split()))
a.sort(reverse = True)
Alice,Bob=0,0
while len(a) != 0:
  if len(a) != 0:
     Alice+=a.pop(0)
  if len(a) != 0:
     Bob += a.pop(0)
print(Alice-Bob)

# Example run
# Input:
vD[-LY)&
11099514
# Output:
11099514
n=int(input())
a=list(map(int,input().split()))
b=0
for j in range(0,n-1):
  for i in range(0,n-1):
    if a[i]<a[i+1]:
      b=a[i]
      a[i]=a[i+1]
      a[i+1]=b
num=0
for x in range(0,n//2):
  num=num+a[2*x]-a[2*x+1]
if n%2==1:
  num+=a[n-1]
print(num)

# Example run
# Input:
0
-6956
# Output:
0
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N = int(input())
aa = inpl()
aa.sort(reverse=True)

f = s = 0
for i in range(N):
	if i%2 == 0:
		f += aa[i]
	else:
		s += aa[i]

print(f-s)


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

# Example run
# Input:
0
-6956
# Output:
0
# coding: utf-8
N=int(input())
A=list(map(int,input().split()))
A.sort(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:
-207
386945
# Output:
0
N=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
x=0
y=0
for i in range(N):
  if i%2==0:
    x+=a[i]
  else:
    y+=a[i]
print(abs(x-y))


# Example run
# Input:
-28608
60
# Output:
0
# ABC088B

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


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


# Example run
# Input:
*Q<ju
23763566
# Output:
23763566
n = int(input())

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

Alice = 0
for i in range(0,n,2):
    Alice += a[i]

Bob = sum(a)-Alice

print(Alice-Bob)


# Example run
# Input:
-749
1960818751
# Output:
-1960818751
# -*- coding: utf-8 -*-

if __name__ == "__main__":
    n = int(input())
    vals = list(map(int, input().split()))

    alice, bob = 0, 0

    for i in range(n//2):
        dum = max(vals)
        alice += dum
        del vals[vals.index(dum)]

        dum = max(vals)
        bob += dum
        del vals[vals.index(dum)]

    if vals:
        alice += vals[0]

    print(alice - bob)

# Example run
# Input:
-29392
-192707
# Output:
-192707
# coding: utf-8
# Your code here!
N=int(input())
a=list(map(int,input().split()))
A=0
B=0


a=sorted(a,reverse=True)

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




# Example run
# Input:
3
-563
# Output:
-563
N=int(input())
a=list(map(int,input().split()))
a.sort()
a=a[::-1]

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


# Example run
# Input:
-104837
-69520
# Output:
-69520
n=int(input())
cards=sorted(list(map(int,input().split())),reverse=True)
Alice=sum(cards[::2])
Bib=sum(cards[1::2])
print(Alice-Bib)

# Example run
# Input:
204095531
1
# Output:
1
N = int(input())
arr = list(map(lambda a: int(a), input().split()))
ordered_arr = sorted(arr)
total_a, total_b = 0, 0

for n in range(N):
    if n%2 == 0:
        total_a += ordered_arr[n]
    else:
        total_b += ordered_arr[n]

print(abs(total_a-total_b))

# Example run
# Input:
0
-1
# Output:
0
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
b = len(a)
a_sum = 0
b_sum = 0
for i in range(b):
    if i % 2 == 0:
        a_sum = a_sum + a.pop(0)
    else:
        b_sum = b_sum + a.pop(0)
print(a_sum-b_sum)

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

alist = list()
for i in range(N):
    alist.append(max(a))
    a.remove(max(a))

Alice = 0
Bob = 0

if N == 1:
  result = alist[0]

elif N % 2 == 0:
  n = int(N/2)
  
  for j in range(n):
  	Alice += alist[(j - 1 )*2 ]
  
  for k in range(n):
  	Bob += alist[(k - 1) *2 + 1]
    
  result = Alice - Bob

else:
  n = int((N + 1)/2)
  
  for j in range(n):
  	Alice += alist[(j - 1 )*2 ]
  
  for k in range(n):
  	Bob += alist[(k - 1) *2 + 1]
    
  result = Alice - Bob




print(result)

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

alice = []
bob = []

while A != []:
	alice.append(max(A))
	A.remove(max(A))
	if A != []:
		bob.append(max(A))
		A.remove(max(A))
	else: 
		break
print(sum(alice)-sum(bob))

# Example run
# Input:
10
-43195
# Output:
-43195
N = int(input())
A = [int(i) for i in range(N)]
A.sort()

if N == 1:
	print(A[0])
else:
	Alice = sum(A[0::2])
	Bob = sum(A[1::2])
	print(Alice-Bob)

# Example run
# Input:
70414
# Output:
-35207
N = int(input())
a = list(map(int, 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]
ans = Alice - Bob
print(ans)

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

alice = 0
bob = 0

while(True):
    a.sort()
    alice += a.pop(-1)
    if a == []:
        break
    a.sort()
    bob += a.pop(-1)
    if a == []:
        break

print(alice-bob)


# Example run
# Input:
-563
183640
# Output:
183640
# https://atcoder.jp/contests/abc088/tasks/abc088_b
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)

alice = 0
bob = 0
for i in range(n//2 + 1):
    if len(a) > 0:
        alice += a.pop(0)
    if len(a) > 0:
        bob += a.pop(0)

print(alice - bob)


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

print(abs(x[0]-x[1]))

# Example run
# Input:
-7737
-126905272
# Output:
0
a = int(input())
b = list(map(int,input().split()))

c = sorted(b,reverse = True)
d = c[0::2]
e = c[1::2]

print(sum(d) - sum(e))

# Example run
# Input:
-3161926
-54
# Output:
-54
N = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
alice, bob = 0, 0
for i, x in enumerate(a):
    if i%2 == 0:
        alice += x
    else:
        bob += x
print(alice - bob)

# Example run
# Input:
30315
-65
# Output:
-65
n = int(input())
list_c = sorted(map(int,input().split()))[::-1]
a = sum(list_c[::2])
b = sum(list_c[1::2])

print(a - b)

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

total_sum = sum(a_list)
a_list = sorted(a_list,reverse=True)

a_sum = 0
for i in range(0,len(a_list),2):
    a_sum += a_list[i]

print(a_sum - total_sum + a_sum)


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

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

a.sort(reverse=True)

al = 0
bo = 0

if N % 2 == 1:
	N -= 1
	al += a[-1]

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

print(al-bo)



# Example run
# Input:
-2
-2
# 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:
255
131163226
# Output:
131163226
n = int(input())
a = list(map(int, input().split()))
alice = 0
bob = 0

a_sort = sorted(a, reverse=True)

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

print(alice-bob)

# Example run
# Input:
-755
-256478906
# Output:
0
N=int(input())
a=[]
a=list(map(int,input().split()))
sortedA=sorted(a,reverse=True)
Alice=0
Bob=0
Alice=sum(sortedA[0::2])
Bob=sum(sortedA[1::2])
print(Alice - Bob)

# Example run
# Input:
-1
25
# Output:
25
N = int(input())
A = sorted(list(map(int, input().split())))

Alice = 0
Bob = 0

while A:
    Alice += A.pop()
    if A:
        Bob += A.pop()

print(Alice - Bob)


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

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

Alice = [a[i] for i in range(0, len(a), 2)]

Bob = [a[i] for i in range(1, len(a), 2)]

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

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


# Example run
# Input:
-132635041
-5036400
# Output:
-5036400
def main():
    N = int(input())
    a = [i for i in map(int, input().split())]
    a = sorted(a, reverse=True)
    alice = sum([j for i, j in enumerate(a) if i % 2 == 0])
    bob = sum([j for i, j in enumerate(a) if i % 2 != 0])
    print(alice - bob)

if __name__ == '__main__':
    main()

# Example run
# Input:
-37
1
# Output:
1
n=int(input())
a=sorted([int(i) for i in input().split()], reverse=True)
ans=sum(a[::2])-sum(a[1::2])
print(ans)

# Example run
# Input:
9
1648
# Output:
1648
# -*- coding:utf-8 -*-
import math

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

A,B =0,0

a.sort()

b = a[::-1]

S = math.floor(N/2)

if (N%2) == 0:
	for i in range (S):
		A = A + b[2*i]
		B = B + b[2*i+1]
else:
	for i in range (S):
		A = A + b[2*i]
		B = B + b[2*i+1]
	A = A + b[N-1]
print(A-B)


# Example run
# Input:
1
-38175
# Output:
-38175
N = int(input())
numbers = input().split()
numbers = list(map(int,numbers))
numbers = sorted(numbers)
even_numbers = sum(numbers[1::2])
odd_numbers = sum(numbers[0::2])
print(abs(odd_numbers - even_numbers))

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


# Example run
# Input:
-16371
-52564348
# Output:
-52564348
# 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:
-274078593
-28418
# Output:
0
n = int(input())
an = list(map(int, input().split()))

alice = 0
bob = 0
an.sort()
an.reverse()
for i,v in enumerate(an):
    if i % 2 ==0:
        alice += v
    else:
        bob += v

print(alice - bob)


# Example run
# Input:
107
186860433
# Output:
186860433
# -*- coding: utf-8 -*-

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

alice = 0
bob = 0
turn = "alice"

a.sort()
a.reverse()

for i in range(n):
    if turn == "alice":
        alice += a[i]
        turn = "bob"
    else:
        bob += a[i]
        turn = "alice"

print(alice-bob)


# Example run
# Input:
-28418
-29
# Output:
0
n=int(input())
li = list(map(int,input().split()))
ca=0
cb=0
li.sort(reverse=True)
for i in range(len(li)):
    #print(i)
    if i%2==0:
        ca+=li[i]
    else:
        cb+=li[i]
print(ca-cb)

# Example run
# Input:
-124978655
-23909
# Output:
-23909
N=int(input())
A_list=list(map(int, input().split()))
A_list = sorted(A_list, reverse=True)
total = 0
for i in range((N+1)//2):
  total = total + A_list[i*2]
print(total-(sum(A_list)-total))

# Example run
# Input:
0
-31
# Output:
31
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt, gcd
from copy import deepcopy
from functools import reduce



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

    print(a-b)

if __name__ == "__main__":
    main()


# Example run
# Input:
-1
-3439167
# Output:
0
N=int(input())
a = [int(i) for i in input().split()] 
a.sort(reverse=True)
p1=a[0:N:2]
p2=a[1:N:2]
sum1=0
sum2=0
for i in p1:
	sum1+=i
for i in p2:
	sum2+=i

print(sum1-sum2)

# Example run
# Input:
70800
72046879
# Output:
72046879
n = int(input())
a = list(map(int, input().split()))
sorted(a, reverse=True)
alice = 0
bob = 0
flag_alice = True
for num in a:
    if flag_alice:
        alice += num
        flag_alice = False
    else:
        bob += num
        flag_alice = True
print(alice - bob)


# Example run
# Input:
2863
7718703
# Output:
7718703
n = int(input())
pre_a = input().split()
a = [int(i) for i in pre_a]
a.sort()

alice = 0
bob = 0
is_alice_turn = True
while 0 < len(a):
    if is_alice_turn:
        alice += a[len(a) - 1]
    else:
        bob += a[len(a) - 1]
    a.pop(len(a) - 1)
    is_alice_turn = not is_alice_turn
print(alice - bob)

# Example run
# Input:
-21000
3
# Output:
3
# coding: utf-8
N = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
print(a)
alice = sum(a[0::2])
bob = sum(a[1::2])
print(alice-bob)

# Example run
# Input:
-56661351
981571
# Output:
[981571]
981571
N = int(input())
a = [int(n) for n 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:
-4868286
-104837
# Output:
0