Felix6326727/beyond-accuracy-code-comprehension huggingface dataset:
N = int(input())
A = [int(x) for x in input().split()]
A.sort()

coef = 1
score = 0
while A:
  score += A.pop() * coef
  coef *= (-1)

print(score)

# Example run
# Input:
1288
-11392175
# Output:
-11392175
a=list(map(int,input().split()))
alice=0
bob=0
a=sorted(a,reverse=True)
while True:
    alice+=a[0]
    a.pop(0)
    if len(a)==0:
        break
    bob+=a[0]
    a.pop(0)
    if len(a)==0:
        break
print(alice-bob)

# Example run
# Input:
2817
# Output:
2817
if __name__ == '__main__':
    N = int(input())
    a_list = list(map(int, input().split()))

    a_list = sorted(a_list, reverse=True)

    answer = 0
    for i in range(len(a_list)):
        if i % 2 == 0:
            if i + 1 <= len(a_list) - 1:
                answer += a_list[i] - a_list[i+1]
            else:
                answer += a_list[i]

    print(answer)


# Example run
# Input:
407083673
113162947
# Output:
113162947
_ = 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:
?J7Ozof
-122062265
# Output:
-122062265
N = int(input())
list_x= list(map(int, input().split(' ')))
Alice, Bob= 0, 0
x = 0
for i in range(N):
    x = max(list_x)
    list_x.remove(x)
    if i % 2 == 0:
        Alice += x
    else:
        Bob += x
print(str(Alice - Bob))

# Example run
# Input:
-877447
8312590
# Output:
0
# -*- coding: utf-8 -*-

#整数値入力 1文字の入力
def input_one_number():
    return int(input())

#整数値龍力　複数の入力
def input_multiple_number():
    return map(int, input().split())

#整数値龍力　複数の入力(配列)
def input_multiple_number_as_list():
    return list(map(int, input().split()))

#2次元配列入力
def input_map():
    return [list(map(int,list(input()))) for i in range(h)]

#リスト出力
def print_list(list):
    print(*list)
    return

#2次元配列出力
def print_map(maplist):
    for i in maplist:print(*i, sep='')
    return

#素数生成
def generate_primenums():
    n = 100
    primes = set(range(2, n+1))
    for i in range(2, int(n**0.5+1)):
        primes.difference_update(range(i*2, n+1, i))
    primes=list(primes)
    return primes

def memo():
    a=[0]*5
    b=a  #良くない配列のコピー
    b2=a[:]  #1次元のときはコピーはこれで良い
    a[1]=3
    print('b:{}, b2:{}'.format(b,b2))  #b:[0, 3, 0, 0, 0], b2:[0, 0, 0, 0, 0]
    
    import copy
    a= [[0]*3 for i in range(5)] #2次元配列はこう準備、[[0]*3]*5だとだめ
    b=copy.deepcopy(a)  #2次元配列はこうコピーする
    
    #内包表記奇数のみ
    odd=[i for i in range(100) if i%2==1] #[1, 3, 5, 7, 9, 11, 13, 15, 17, 19]

    #二部探索
    import bisect
    a = [1, 2, 3, 5, 6, 7, 8, 9]
    b=bisect.bisect_left(a, 8)

    #combinations、組み合わせ、順列
    from itertools import permutations, combinations,combinations_with_replacement,product
    a=['a','b','C']
    print(list(permutations(a)))
    print(list(combinations(a,2)))
    print(list(combinations_with_replacement(a,3)))


#階乗
def kaijo(n):
    import math
    return math.factorial(n)

#選び方（コンビネーション nCr）
def num_combination(n,r):
    import math
    return math.factorial(n) // math.factorial(n - r)


#最大公約数、最小公倍数
def calc_gcd(a,b):
    import fractions
    GCD=fractions.gcd(a,b)
    lcm=a*b//gcd
    return gcd,lcm

#複数の最大公約数
def calc_gcd_list(l):
    gcd = l[0]
    for i in range(1, N):
        gcd = fractions.gcd(gcd, l[i])
    return gcd

#各桁の和
def sum_digit(n):
    sum = 0
    while n > 0:
        sum += n%10
        n //= 10
    return sum

N = input_one_number()
lst_a = input_multiple_number_as_list()

lst_a.sort(reverse=True)

alice = 0
bob = 0

if len(lst_a) %2 == 1:
    lst_a.append(0)

for i in range(len(lst_a)//2):
    alice += lst_a[i*2]
    bob += lst_a[i*2+1]

print(alice-bob)


# Example run
# Input:
56
-87
# Output:
-87
n = int(input())
al = list(map(int, input().split()))
al.sort(reverse=True)
ali = 0
bob = 0
for i,a in enumerate(al):
    if i%2 == 0: ali += a
    else: bob += a

print(ali-bob)


# Example run
# Input:
-38181262
41286958
# Output:
41286958
length = int(input())
cards = list(map(int,input().split()))
sorted_cards = sorted(cards, reverse=True)
Alice_sum = sum(sorted_cards[0::2])
Bob_sum = sum(sorted_cards[1::2])
print(Alice_sum-Bob_sum)

# Example run
# Input:
-307298630
-1794
# Output:
-1794
n=int(input())
a=b=0
p=sorted(list(map(int,input().split())),key=int,reverse=True)
p.append(0)
for i in range(int((n+1)/2)):
    a+=p.pop(0)
    b+=p.pop(0)
print(a-b)

# Example run
# Input:
-489
-8056
# Output:
0
n = int(input())
a = list(map(int, input().split()))
alice = 0
bob = 0

a.sort(reverse = True)
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:
0
-83
# Output:
0
N = int(input())
a = list(map(int, input().split()))
a.sort()
alice = 0
bob = 0
cnt = 0
for i in a:
    if cnt%2==0:
        alice += i
    else:
        bob += i
    cnt += 1

print(abs(alice-bob))

# Example run
# Input:
141725276
-109089799
# Output:
109089799
N = int(input())

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

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


# Example run
# Input:
-86077887
14
# Output:
0
n = int(input())

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

#print(a)

score1 = []
score2 = []

while len(a) > 0:
    pick = max(a)
    score1.append(pick)
    a.remove(pick)
    if len(a) == 0:
        break
    
    pick = max(a)
    score2.append(pick)
    a.remove(pick)
    
#print(score1)
#print(score2)
print(sum(score1) - sum(score2))

# Example run
# Input:
-1800135697
415326
# Output:
415326
N = int(input())
A = list(map(int,input().split()))
A = sorted(A,reverse=True)
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:
-6163826
139893
# Output:
139893
def li():
    return list(map(int, input().split()))


def mi():
    return map(int, input().split())


def ii():
    return int(input())


N = ii()
a = li()

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:
805965556
-19
# Output:
-19
n=int(input())
a=[int(i) for i in input().split()] 
a.sort()
#print(a)
ans=0
for i in range(n):
  ans+=(-1)**i*int(a[-1-i])

print(int(ans))

# Example run
# Input:
1
-12503953
# Output:
-12503953
N = int(input())
a = [int(x) for x in input().split()]
a.sort()
bob = 0
i = 0
while 2*i + 1 < len(a):
    bob = bob + a[2*i + 1]
    i += 1

print(sum(a) - 2*bob)

# Example run
# Input:
-5
-2147483648
# Output:
-2147483648
# -*- coding: utf-8 -*-
# 整数の入力
N = int(input())
cards = [int(s) for s in input().split()]

alice_total = 0
bob_total = 0

cards.sort(reverse=True)

for i in range(len(cards)):
  if i % 2 == 0:
    alice_total += cards[i]
  else:
    bob_total += cards[i]

diff = alice_total - bob_total
print(diff)


# Example run
# Input:
14
-16733
# Output:
-16733
# 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(a - b)

# Example run
# Input:
1
87
# Output:
87
N = int(input())
cards = [int(i) for i in input().split()]
alice = 0
bob = 0
for i in range(N):
    if i % 2 == 0:
        alice += max(cards)
        cards.remove(max(cards))
    elif i % 2 == 1:
        bob += max(cards)
        cards.remove(max(cards))
print(alice - bob)

# Example run
# Input:
-21
6534
# Output:
0
def resolve():
    input()
    num = list(map(int, input().split()))
    num.sort(reverse=True)
    count = 1
    alice = 0
    bob = 0
    for val in num :
        if count % 2 == 0:
            bob += val
        else:
            alice += val
        count += 1
    print(alice - bob if alice >= bob else bob - alice)

if __name__ == '__main__':
        resolve()

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

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



# Example run
# Input:
-1643990
363865392
# Output:
0
N = int(input())
a = sorted([int(i) for i in input().split()],reverse=True)
A = sum(a[0::2])
B = sum(a[1::2])
print(A-B)

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

# Example run
# Input:
YZ@pAFA?
-6003607
# Output:
-6003607
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
A.reverse()
if N % 2 == 0:
    print(sum(A[: N // 2]) - sum(A[N // 2 :]))
else:
    print(sum(A[: N // 2 + 1]) - sum(A[N // 2 + 1 :]))


# Example run
# Input:
2
-7698469
# Output:
-7698469
n = int(input())
a = [int(i) for i in input().split()]
A = 0
B = 0

a.sort()
while len(a) > 0:
    A += a.pop()

    if len(a) > 0:
        B += a.pop()

print(A-B)


# Example run
# Input:
20480
1510792572
# Output:
1510792572
N = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse = True)

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

print( "{}".format( abs( even-odd ) ) )

# Example run
# Input:
-80
-7517
# Output:
0
N = int(input())

a = sorted([int(x) for x in input().split()],reverse=True)

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

# Example run
# Input:
-4
1363926
# Output:
1363926
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:
-31
-58867430
# Output:
0
x = int(input())
y = [int(i) for i in input().split()]
y.sort(reverse=True)
a = 0
b = 0
for i in range(1, x+1):
    if (i % 2) != 0:
        a += y[i-1]
    else:
        b += y[i-1]
print(a-b)

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

sortedList = sorted(li, reverse=True)

alice = 0
bob = 0
turn = 1

while(len(sortedList)):
  if turn % 2 == 1:
    alice += sortedList.pop(0)
  else:
    bob += sortedList.pop(0)
  
  turn += 1

print(alice - bob)

# Example run
# Input:
743812855
1451
# Output:
1451
#encoding:utf-8

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

A.sort(reverse=True)
answer = 0
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:
1
-227348
# Output:
-227348
N = int(input())
A = list(map(int, input().split()))
a = list()
b = list()

if N%2 == 0:
    for i in range(N//2):
        a.append(max(A))
        A.remove(max(A))
        b.append(max(A))
        A.remove(max(A))       
else:
    for i in range(N//2):
        a.append(max(A))
        A.remove(max(A))
        b.append(max(A))
        A.remove(max(A))   
    a.append(max(A))

print(sum(a) - sum(b))

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

# Example run
# Input:
-59
2
# Output:
0
# -*- coding: utf-8 -*-

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:
-58743
-207
# Output:
0
n = int(input())
a = list(map(int, input().split()))
alice = 0
bob = 0
a.sort()
for i in range(n):
    if i%2==0:
        alice += a[-1]
        a.pop()
    elif i%2==1:
        bob += a[-1]
        a.pop()
print(alice-bob)

# Example run
# Input:
0
8131
# Output:
0
i = int(input())
nums = list(map(int,input().split()))
num = sorted(nums,reverse=True)
a = 0
b = 0
for index,n in enumerate(num):
	if (index+1)  % 2 != 0:
		a += n
	else:
		b += n
print(a-b)

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

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

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

alice = []
bob = []
for i in range(1, n+1):
    val = max(card)
    del card[card.index(val)]
    if i % 2 == 1:
        alice.append(val)
    else:
        bob.append(val)

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



# Example run
# Input:
-23909
-68
# Output:
0
#coding:utf-8

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

A_lis = sorted(A)
c = 1
score = 0

for i in range(N):
    n = A_lis.pop()
    if c%2 == 0:
        score -= n
    elif c%2 == 1:
        score += n
    c += 1

print(score)


# Example run
# Input:
-2
-32942311
# Output:
0
n = int(input())
a = list(map(int, input().split()))
sort_a = sorted(a, reverse=True)
alice = [sort_a[i] for i in range(n) if i%2==0]
bob = [sort_a[i] for i in range(n) if i%2!=0]
point_alice = sum(alice)
point_bob = sum(bob)
print(point_alice - point_bob)

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

# Example run
# Input:
WFHM
1810607153
# Output:
1810607153
N = int(input())
a = list(map(int, input().split()))
A = []
B = []

if len(a) % 2 == 1:
	A.append(min(a))
	a.remove(min(a))

while len(a) > 0:
	A.append(max(a))
	a.remove(max(a))
	B.append(max(a))
	a.remove(max(a))

print(sum(A) - sum(B))

# Example run
# Input:
65211
-69919
# Output:
-69919
n = input()
aa = list(map(int, input().split()))
aa.sort(reverse=True)
al = sum(aa[::2])
bb = sum(aa[1::2])
print(al - bb)


# Example run
# Input:
4EPy8r+|E
51856
# Output:
51856
N = int(input())
A = [int(i) for i in input().split()]
a = sorted(A,reverse=True)
alice = sum(a[0::2])
bob = sum(a[1::2])
print(alice - bob)

# Example run
# Input:
18575536
-48655
# Output:
-48655
# -*- coding: utf-8 -*-
#input number
num = int(input())
str = input()
#change to list distinguished by space
list = str.split()

#arrange number from high number to low number
list.sort(reverse=True)

sum = 0
for (i, v) in enumerate(list):
  if i == num:
    break
  else:
    if(i % 2 == 0):
      sum += int(v)
    elif(i % 2 == 1):
      sum -= int(v)
print(sum)

# Example run
# Input:
-331
18
# Output:
18
N = int(input())

if N%2 == 0:
  print(N/2)
else:
  print(N/2 + 1)

# Example run
# Input:
-48
# Output:
-24.0
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:
8
-2222
# Output:
-2222
n=int(input())
a=sorted(list(map(int,input().split())))
print(sum(a[-1::-2])-sum(a[-2::-2]))


# Example run
# Input:
-54634663
3615919
# Output:
3615919
N = int(input())
A = [int(s) for s in input().split()]
A.sort()
vA = 0;
vB = 0;
for i in range(N):
    if (len(A) == 0):
        break
    vA += A.pop()
    if (len(A) == 0):
        break
    vB += A.pop()
print(vA - vB)


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

c = 0
a.sort(reverse=True)
for i in range(N):
  if i//2 == 0:
    c += a[i]
  else:
    c -= a[i]
print(a[i])

# Example run
# Input:
1
-1012372
# Output:
-1012372
N = int(input())
A = B = 0
li = list(map(int, input().split()))
N_li = sorted(li, reverse=True)
for i in range(N):
  if i%2==0:
    A += N_li[i]
  else:
    B += N_li[i]
print(A - B)

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

A.sort()
A.reverse()
Alice = sum(A[0::2])
Bob = sum(A[1::2])

print(Alice - Bob)

# Example run
# Input:
-210
49968
# Output:
49968
n = int(input())

a = []
a = list(map(int, input().split()))

b = sorted(a, reverse=True) # reverse = Trueは降順
# print(b)
# print(b[0])

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


# Example run
# Input:
-377
-491914923
# Output:
0
n = int(input())
a = sorted(list(map(int,input().split())), 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:
-18086578
60
# Output:
60
N = input()
As = list(map(int, input().split()))

Alice = []
Bob = []

while(As):
    Alice.append(max(As))
    As.remove(max(As))
    if not As:
        break
    Bob.append(max(As))
    As.remove(max(As))

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

# Example run
# Input:
xkU){S*1
-640183291
# Output:
-640183291
n = int(input())
a = [int(x) for x in input().split()]
a.sort(reverse=True)

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


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

alice = 0
bob = 0
for i in range(N):
  if i % 2 == 0:
    alice += alist.pop(alist.index(max(alist)))
  else:
    bob += alist.pop(alist.index(max(alist)))
    
print(alice-bob)

# Example run
# Input:
1
-124978655
# Output:
-124978655
N = int(input())
a = sorted(map(int, input().split()), 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:
1
-3
# Output:
-3
N = int(input())
data = list(map(int, input().split()))
Alice = 0
Bob = 0
count = 0
while N > count:
  high = data[0]
  point = 0
  for i in range(N):
    if data[i] > high:
      high = data[i]
      point = i
  if count % 2 == 0:
    Alice += high
  else:
    Bob += high
  data[point] = 0
  count += 1
print(Alice - Bob)

# Example run
# Input:
-80
-7517
# 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(x-y)

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

alice = []
bob = []
sorted_cards = sorted(a, reverse=True)

for i, v in enumerate(sorted_cards):
    if i % 2 == 0:
        alice.append(v)
    else:
        bob.append(v)

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

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

print(abs(s))

# Example run
# Input:
16
-181
# Output:
181
n=int(input())
L=list(map(int,input().split()))

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

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

Alice = 0
Bob = 0

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

print(Alice - Bob)

# Example run
# Input:
-52564348
-7737
# Output:
-7737
n = int(input())
l = list(map(int,input().split()))
a = 0
b = 0
for i in range(n):
    if i%2==0:
        a+=max(l)
        del l[l.index(max(l))]
    else:
        b+=max(l)
        del l[l.index(max(l))]
print(a-b)

# Example run
# Input:
-686
15761764
# 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
-22340
# Output:
-22340
i = int(input())
card = list(map(int,input().split(' ')))
card.sort(reverse=True)
#print(card)
alice = card[0::2]
bob = card[1::2]
print(sum(alice)-sum(bob))
#print(bob)

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

a_sort = sorted(a)[::-1]
Alice = 0
Bob = 0
for i in range(0,N):
	if i%2 == 0:
		Alice += a_sort[i]
	if i%2 == 1:
		Bob += a_sort[i]

print(Alice-Bob)


# Example run
# Input:
-75
57223618
# Output:
0
n = input()
li = list(map(int,input().split()))
li.sort(reverse=True)
Alice = 0
Bob = 0
count = 1
for i in li:
    if count % 2:
        Alice += i
        count += 1
        print(count,Alice)
    else:
        Bob += i
        count += 1
        print(count,Bob)
print(Alice - Bob)



# Example run
# Input:
$an
3
# Output:
2 3
3
n = int(input())
cards = list(map(int, input().split()))
cards.sort(reverse=True)
alice = 0
bob = 0
alice_cards = cards[::2]
bob_cards = cards[1::2]
alice_sum = sum(alice_cards)
bob_sum = sum(bob_cards)
print(alice_sum - bob_sum)


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

a.sort()

ALICE = sum(a[::2])
BOB = sum(a[1::2])

print(ALICE-BOB)

# Example run
# Input:
-48845357
-118998188
# Output:
-118998188
n=int(input())
#list内包表記で書こう
#速いし、書きやすい
a=sorted([int(i) for i in input().split()],reverse=True)
b=0
for i in range(n):
    if i%2==0:
        b+=a[i]
    else:
        b-=a[i]

print(b)


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

# Example run
# Input:
-3
24
# 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:
15914
29
# Output:
29
n = int(input())
a = list(map(int, input().split()))
a.sort()

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

print(alice - bob)

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

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


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

# Example run
# Input:
4
4
# Output:
4
N=int(input())
A=[int(x) for x in input().split()]
A.sort(reverse=True)

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:
-1002
45236
# Output:
45236
n = int(input())
A = list(map(int,input().split()))
alice = 0
bob = 0
A = sorted(A)
for i in range(n):
    if i % 2 == 0:
        alice += A[n - 1 - i]
    else:
        bob += A[n - 1 - i]
print(alice - bob)


# Example run
# Input:
-19797306
311070
# Output:
0
#coding:utf-8

n = int(input())

nums = list(map(int,input().split(' ')))
nums = sorted(nums, reverse=True)
diff = 0
for i in range(n):
  if i % 2 == 0:
    diff += nums[i]
  else:
    diff -= nums[i]
print(diff)

# Example run
# Input:
-58867430
-56661351
# Output:
0
N = input()
cards = list(map(int, input().split()))

apoint = 0
bpoint = 0
while True:
	apoint = max(cards)
	cards.remove(max(cards))

	if len(cards) == 0:
		break

	bpoint = max(cards)
	cards.remove(max(cards))

	if len(cards) == 0:
		break

dif = apoint - bpoint
print(dif)

# Example run
# Input:
|Au
-330
# Output:
-330
n=int(input())
Cards=sorted(list(map(int, input().split())), reverse=True)
Alice=Cards[0:n:2]
Bob=Cards[1:n:2]
print(sum(Alice)-sum(Bob))

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

alice=0
bob=0

for i in range(n):
    if i%2==0:
        alice+=newL[i]
    elif i%2==1:
        bob+=newL[i]
print(alice-bob)

    

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

a.sort(reverse = True)

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:
4195951
98
# Output:
98