Felix6326727/beyond-accuracy-code-comprehension huggingface dataset:
N=int(input())
listA=list(map(int,input().split()))
listA.sort(reverse=True)
a=0
b=0
for i in range(N):
  if i%2==0:
    a+=listA[i]
  else:
    b+=listA[i]
print(a-b)    

# Example run
# Input:
-206075
-1
# Output:
0
S=0
N = int(input())
l = map(int, input().split())

l = list(sorted(l))

for i in range(1, N+1):
    if i%2 == 1:
        S+=l[N-i]
        #print(S)
    else:
        S-=l[N-i]
        #print(S)
            

#print('--------')
print(S)

# Example run
# Input:
-84564737
-18579092
# Output:
0
n = int(input())
a = map(int, input().split())

a = sorted(a)[::-1]

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

# Example run
# Input:
260615611
20794
# Output:
20794
n=int(input())
lista=list(map(int,input().split()))
lista.sort(reverse=True)
alice=list()
bob=list()
for i in range(n):
    if i%2==0:
        alice.append(lista[i])
        
    else: 
        bob.append(lista[i])
print(alice)
print(sum(alice)-sum(bob))

# Example run
# Input:
-54634663
3615919
# Output:
[]
0
# coding: utf-8
import sys


def main():
  n = int(input())
  card = sorted(list(map(int, input().split(' '))), reverse=True)
  A = []
  B = []
  
  for i in range(n):
    if i % 2 == 0:
      A.append(card[i])
    
    else:
      B.append(card[i])
      
  print(sum(A) - sum(B))
  
  return 0


if __name__ == '__main__':
  main()

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



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

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

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

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

result = 0
is_even = True
for x in a:
    result += x if is_even else -x
    is_even = not is_even
print(result)

# Example run
# Input:
19239
-331
# Output:
-331
N = int(input())
Z = list(map(int, input().split()))
Z.sort(reverse=True)
A = sum([Z[i] if i % 2 == 0 else 0 for i in range(N)])
B = sum([Z[i] if i % 2 == 1 else 0 for i in range(N)])
print(A-B)

# Example run
# Input:
-31081879
2
# 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 == 1:
    score_alice += cards[i]
  else:
    score_bob += cards[i]

print(score_alice - score_bob)

# Example run
# Input:
-596
444572227
# Output:
0
N = int(input())
list1 = list(map(int,input().split()))

list1.sort(reverse=True)

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

print(alice - bob)


# Example run
# Input:
-31
-58867430
# Output:
-58867430
import sys
from functools import reduce
import copy
import math
from pprint import pprint


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    cards = string_to_int(inputs[0])
    cards.sort(reverse=True)
    count_a = 0
    count_b = 0
    turn_a = True
    for card in cards:
        if turn_a:
            count_a += card
        else:
            count_b += card
        turn_a = not turn_a
    return count_a - count_b


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)


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

# Example run
# Input:
-1836
-168854
# Output:
-168854
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:
-1
-2
# Output:
0
N = int(input())
A = list(map(int, input().split()))

AS = sorted(A,reverse=True)
ans = 0
for i in range(len(AS)):
    if(i%2==0):
        ans += AS[i]
    else:
        ans -= AS[i]

print(ans)

# Example run
# Input:
981571
-6163826
# Output:
-6163826
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
k=0
l=0

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

# Example run
# Input:
-1
3478382
# Output:
0
n = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
#print(A)
Alice = []
Bob = []
for i in range(n):
    if i%2 != 0:
        Alice.append(A[i])
    else:
        Bob.append(A[i])
print(abs(sum(Alice) - sum(Bob)))

# Example run
# Input:
-97075663
1
# Output:
0
N = int(input())
arr = list(map(int, input().split()))
new_arr = sorted(arr)

bob   = 0
alice = 0

for i in range(len(new_arr)):
    if i % 2 ==0:
        alice += new_arr[i]
    elif i % 2 ==1:
        bob += new_arr[i]

print(abs(alice-bob))

# Example run
# Input:
35
-842467
# Output:
842467
n = int(input())
a = [int(x) for x in input().split()]

a.sort(reverse=True)
alice = a[0::2]
bob = a[1::2]

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

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

# ソートを行う
sortList = sorted(A, reverse=True)

# 配列
alice = []
bob = []

# 奇数がAlice
for i in range(len(sortList)):
        if i % 2 == 0:
                alice.append(sortList[i])
        if i % 2 != 0:
                bob.append(sortList[i])

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

# Example run
# Input:
-6956
-7038374
# Output:
-7038374
n=int(input())
a_list=list(input().split())

a = 0
b = 0
a_list_sorted = a_list.sort(reverse=True)

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

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

print(alice - bob)

# Example run
# Input:
-37
1
# Output:
1
if __name__=='__main__':
    N = int(input())
    a = list(map(int, input().split(' ')))
    a.sort()
    a = a[::-1]

    Alice = [a[i] for i in range(N) if i % 2 == 0]
    Bob = [a[i] for i in range(N) if i % 2 == 1]

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

# Example run
# Input:
-97071
36241
# Output:
0
import sys
from collections import Counter, deque, defaultdict
from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
from functools import reduce
from math import ceil, floor, log10, log2, factorial
from pprint import pprint

sys.setrecursionlimit(1000000)
# MOD = 10 ** 9 + 7
# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]

N = int(input())
A = [int(x) for x in input().split()]
A.sort(reverse=True)
a = sum(A[0::2])
b = sum(A[1::2])

print(a - b)


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

a.sort(reverse=True)

Alice_point = 0
Bob_point = 0

for i, value in enumerate(a):
    if i % 2 == 0:
        Alice_point += value
    else:
        Bob_point += value

print(Alice_point - Bob_point)


# Example run
# Input:
-1
-3439167
# Output:
-3439167
import math
N=int(input())
a=list(map(int,input().split()))
a=sorted(a)
alice=0
bob=0
if(N%2==0):
    for i in range(0,N-1,2):
        alice=a[i+1]+alice
        bob=a[i]+bob
else:
    for i in range(1,N-1,2):
        alice=a[i+1]+alice
        bob=a[i]+bob
    alice=alice+a[0]
print(alice-bob)

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

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

# Example run
# Input:
-126905272
28016
# Output:
28016
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input())
    a = list(int(_) for _ in input().split())
    a.sort()
    a = a[::-1]
    ans = 0
    for i in range(N):
        if i % 2 == 0:
            ans += a[i]
        else:
            ans -= a[i]
    print(ans)
    
if __name__ == '__main__':
    main()


# Example run
# Input:
-3339504
3556893
# Output:
0
N = input()
a = list(map(int, input().split()))
a.sort(reverse=True)
ans = 0
for (x,i) in enumerate(a):
  if x%2==0:
    ans += i
  else:
    ans -= i
print(ans)

# Example run
# Input:
-`2,MZ0JC
-224960337
# Output:
-224960337
def main():
    num = int(input())
    data = list(map(int, input().split()))
    data.sort(reverse=True)

    aaa = sum(data[::2])
    bbb = sum(data[1::2])

    print(aaa - bbb)



if __name__ == '__main__':
    main()

# Example run
# Input:
-2811762
15761764
# Output:
15761764
#!/usr/bin/env python3

n = int(input())
ai = list(map(int, input().split()))
assert len(ai) == n
ai = sorted(ai, reverse=True)

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

print(ali - bob)


# Example run
# Input:
1
3770
# Output:
3770
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:
-80
-7517
# Output:
0
int(input())
a=list(map(int, input().split()))
a.sort(reverse=True)
ans=sum(a[::2])-sum(a[1::2])
print(ans)

# Example run
# Input:
-6865
446
# Output:
446
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse = True)
Sabun = 0
for i in range(len(A)):
    if i % 2 == 0:
        Sabun += A[i]
    elif i % 2 == 1:
        Sabun -= A[i]
print(Sabun)

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

a_n.sort(reverse=True)
alice = a_n[0: len(a_n): 2]
bob = a_n[1: len(a_n): 2]

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

# Example run
# Input:
331737
-5271130
# Output:
-5271130
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:
-398
986892
# Output:
0
N = int(input())
ls = [int(s) for s in input().split()]
ls = sorted(ls,reverse=True)
alice = 0
bob = 0
for i in range(N):
  if i%2==0:
    alice += ls[i]
  else:
    bob += ls[i]
print(alice-bob)

# Example run
# Input:
-812896393
-97075663
# Output:
0
N = int(input())
a = []
astr = input().split()
for i in astr:
    a.append(int(i))

sorteda = sorted(a)

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

print(Alice-Bob)

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

# Example run
# Input:
-37
1
# Output:
1
N = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
Alice,Bob = 0,0
for i in range(N):
    if i % 2 == 0:
        Alice += a[i]
    else:
        Bob += a[i]

print(Alice - Bob)

# Example run
# Input:
-230914
-246934
# Output:
0
n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
Alice = 0
for i in range(0, n, 2):
    Alice += l[i]
Bob = sum(l) - Alice
print(abs(Bob - Alice))


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

# Example run
# Input:
-21
6534
# Output:
0
N=int(input())
numbers=list(map(int,input().split()))
for i in range(N):
    for k in range(i+1):
        if numbers[k]<numbers[i]:
            temp=numbers[k]
            numbers[k]=numbers[i]
            numbers[i]=temp
            break
Alice=0

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

# Example run
# Input:
-7930
-86
# 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:
-54634663
3615919
# Output:
3615919
n=input() 
l=sorted(map(int,input().split()),reverse=True)
print(sum(l[::2])-sum(l[1::2]))

# Example run
# Input:
VI3R
-98031
# Output:
-98031
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]
print(alice - bob)

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

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

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

print(Alice-Bob)

# Example run
# Input:
-8056
-449705
# Output:
-449705
def resolve():
    n = int(input())
    a = [int(i) for i in input().split()]
    a = sorted(a, reverse=True)
    alice = a[0::2]
    bob = a[1::2]
    print(sum(alice) - sum(bob))

resolve()

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


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

B=sorted(A,reverse=True)
alice_num=0
bob_num=0

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

print(alice_num-bob_num)      

# Example run
# Input:
-32942311
298151
# Output:
0
input()

AT = 0
Nob = 0
count = 0
for i in reversed(sorted(list(map(int, input().split())))):
    if(count % 2 == 0):
        AT += i
    else:
        Nob += i
    count += 1
print(AT-Nob)

# Example run
# Input:
T0%'^}\p
5
# Output:
5
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]

ans = alice - bob
print(ans)


# Example run
# Input:
-40
0
# Output:
0
""" AtCoder """

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

a.sort(reverse = True)
f = 1
ans = 0

for i in range(N):
    ans += a[i] * f
    f *= -1

print(ans)


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

# Example run
# Input:
<g/Mjkn_<
-56
# Output:
-56
n = int(input())
A = list(map(int, input().split()))

A = list(sorted(A, reverse=True))

ret = 0

for i in range(0, n):
    if i % 2 == 0:
        ret += A[i]
    else:
        ret -= A[i]

print(ret)


# Example run
# Input:
-124978655
-23909
# 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:
197766
-101281970
# Output:
-101281970
N=int(input())
A=input()
allcards=A.split()
for i in range (len(allcards)):
    allcards[i]=int(allcards[i])
allcards.sort()
alice=[]
bob=[]
alicet=True
bobt=False

for a in allcards:
    if alicet == True :
        alice.append(a)
        alicet=False
        bobt=True
    elif bobt == True:
        bob.append(a)
        bobt=False
        alicet=True

alicesum=sum(alice)
bobsum=sum(bob)

if alicesum - bobsum > 0 :
    print(alicesum - bobsum)
else :
    print(bobsum - alicesum)

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

Alice = 0
Bob = 0
A.sort(reverse=True)
for i in range(len(A)):
    if i%2 == 0:
        Alice += A[i]
    else:
        Bob += A[i]
    
print(Alice-Bob)

# Example run
# Input:
23587
2
# Output:
2
n = int(input())
card = list(map(int,input().split()))
card = sorted(card,reverse=True)
alice = 0
bob = 0

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

print(alice-bob)


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

# Example run
# Input:
f}C#D\QF
-260
# Output:
-260
# atcoder では WAになる。なんで。
N = int(input())
a = list(map(int,input().split()))
a = sorted(a,reverse =True)
#
alice = []
bob = []
alice_total = 0
bob_total = 0
ans = 0
#
if N%2 == 0:
    for i in range(int(N/2)):
        alice.append(a[2*i])
        bob.append(a[2*i + 1])
elif N!=1 and N%2==1:
    for j in range(int((N - 1)/2)):
        alice.append(a[2*j])
        alice.append(a[N - 1])
        bob.append(a[2*j + 1])
else:
    alice = a
#
alice_total = sum(alice)
bob_total = sum(bob)
ans = alice_total - bob_total
#
print(ans)


# Example run
# Input:
0
-84521052
# Output:
0
n=int(input())
a=list(input().split(" "))
a=list(map(int,a))
a.sort(reverse=True)
alic=[]
bob=[]
for i in range(0,n):
    if i==0 or i%2==0:
        alic.append(a[i])
    else:
        bob.append(a[i])
print(sum(alic)-sum(bob))

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

Alice, Bob = 0, 0

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

print(Alice - Bob)


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

a.sort()
a.reverse()
b = []
c = []
for i in range(N):
    if i % 2 == 0:
        b.append(a[i])
    else:
        c.append(a[i])
b_sum = 0
c_sum = 0
for i in b:
    b_sum += i
for i in c:
    c_sum += i

print(b_sum - c_sum)

# Example run
# Input:
-24
-1198338
# Output:
0
#!/usr/bin/env python3

from math import *
from itertools import *
from collections import *
from bisect import *


if __name__ == '__main__':
    input()
    lst = [int(x) for x in input().split()]
    lst.sort(reverse=True)
    n = sum(lst)
    na = sum(lst[::2])
    print(na-n+na)


# Example run
# Input:
S*<;
13764
# Output:
13764
n=int(input())
a=[]
a=list(map(int,input().split()))
a.sort()
a.reverse()
alice=[]
bob=[]
for i in range (0,n):
    if i%2==0:
        alice.append(a[i])
    else :
        bob.append(a[i])
print(sum(alice)-sum(bob))


# Example run
# Input:
-831
110
# Output:
0
N=int(input())
an=map(int,input().split())
Cards=[]
for a in an:
    Cards.append(int(a))
Cards.sort
AliceCards=Cards[0::2]
BobsCards=Cards[1::2]
print(sum(AliceCards)-sum(BobsCards))



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

# Example run
# Input:
-224960337
446
# Output:
446
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:
-64
98020
# 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.appemd(li[i])
  else:
    if i%2==0:
      b.append(li[i])
    else:
      a.append(li[i])
print(sum(a)-sum(b))

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

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:
-1991
-9
# Output:
0
n=int(input())
a=sorted(list(map(int,input().split())),reverse=True)
ans=sum(a[::2])-sum(a[1::2])
print(ans)

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

# Example run
# Input:
11
4082171
# Output:
4082171
N = int(input())
alist = input().split()
alist = sorted(alist, reverse=True)
count = 1
alice = 0
bob = 0

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

# Example run
# Input:
-40780112
-13
# Output:
-13
N = int(input())
A = [int(i) for i in input().split()]

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

# Example run
# Input:
-4868286
-104837
# Output:
-104837
N = int(input())
A = list(map(int,input().split()))
A.sort()
A.reverse()
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:
-84521052
-2
# Output:
0
N = int(input())
a = []
a = input().split(' ')
a = [int(i) for i in a]
a = sorted(a, reverse=True)
Alice = 0
Bob = 0
for i in range(N):
  if i == 0:
    Alice += a[i]
  elif i%2 == 0:
    Alice += a[i]
  elif i%2 == 1:
    Bob += a[i]

print(Alice - Bob)

# Example run
# Input:
-1
-3439167
# Output:
0
N = int(input())
a = [int(x) for x in input().split()]
Alice = 0
Bob = 0

for i in range(N):
  max_val = max(a)
  max_idx = a.index(max_val)
  
  if i % 2 == 0:
    Alice += max_val
  else:
    Bob += max_val
  del a[max_idx]

print(Alice - Bob)

# Example run
# Input:
0
-84521052
# Output:
0
N = int(input())
a = [int(i) for i 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:
-2147483648
3556893
# Output:
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:
-9
-13574883
# Output:
-13574883
c = 0
N = int(input())
A = list(map(int, input().split(" ")))
A.sort()
for i in range(N):
    if i % 2 != 0:
        c+=A[i]
    else:
        c-=A[i]
print(c)

# Example run
# Input:
-439
20405993
# Output:
0
n = int(input())
l = sorted(list(map(int, input().split())))[::-1]
sum = 0
for i in range(n):
  if i%2==0:
    sum +=l[i]
  else:
    sum -=l[i]
print(sum)

# Example run
# Input:
-109089799
-74270783
# Output:
0
n=int(input())
a=list(map(int,input().split()))
c=0
d=0
a.sort()
e=len(a)-1
f=0
while(e>=0):
	if(f==0):
		c+=a[e]
		f=1
	elif(f==1):
		d+=a[e]
		f=0
	e-=1
print(c-d)			


# Example run
# Input:
-17
-153163
# Output:
-153163
N = int(input())
A = list(map(int,input().split()))
A_res = 0
B_res = 0
for i in range(N):
    if i % 2 == 1:
        A_res += max(A)
    else:
        B_res += max(A)
    del A[A.index(max(A))]

print(B_res - A_res)

# Example run
# Input:
-168854
-5
# Output:
0
n = int(input())
a_list = list(map(int, input().split()))
alice = 0
bob = 0


for i in range(len(a_list)):
    if i % 2:
        bob += sorted(a_list)[i]
    else:
        alice += sorted(a_list)[i]

print(str(alice - bob)) 

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

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

# Example run
# Input:
-1
-3439167
# Output:
0
alice = 0
bob= 0

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

for i in range(N):
    max_num = max(a)
    if i % 2 == 0:
        alice += max_num
    else:
        bob += max_num
    a.remove(max_num)

print(alice - bob)


# Example run
# Input:
0
-1140169349
# Output:
0