Felix6326727/beyond-accuracy-code-comprehension huggingface dataset:
n = input()
cards = sorted(list(map(int, input().split())))[::-1]
alice = cards[0::2]
bob = cards[1::2]
print(sum(alice) - sum(bob))

# Example run
# Input:
AY`
31481447
# Output:
31481447
N=int(input())
A=sorted(list(map(int, input().split())))
even_sum=sum(A[0::2])
odd_sum=sum(A[1::2])
print(abs(even_sum-odd_sum))

# Example run
# Input:
-647437
346
# Output:
346
n=int(input())
x=list(map(int,input().split()))
x.sort()
x=x[::-1]
cnt=0
a=0
b=0
for i in x:
  if cnt%2==0:
    a+=i
    cnt+=1
  else:
    b+=i
    cnt+=1
print(a-b)

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

# Example run
# Input:
1593280440
2
# Output:
2
import math
N = int (input ())
l = input ().split ()
l = [int(s) for s in l]
list.sort (l, reverse=True)
a = 0
x = 0
m = math.ceil(N/2)
for i in range (m):
    x += int (l[a])
    a += 2
a = 1
y = 0
for i in range (N-m):
    y += int (l[a])
    b += 2
print (x-y)

# Example run
# Input:
-7517
134
# Output:
0
N = input()
li2 = input().split()
li = []
for l in li2:
  li.append(int(l))
li.sort()
li.reverse()
t = 0
ans = 0
for i in li:
  if t % 2 == 0:
    ans += int(i)
  else:
    ans -= int(i)
  t += 1

print(ans)

# Example run
# Input:
Br7-
-2
# Output:
-2
def main():
    n = int(input())
    cards = [int(i) for i in input().split()]

    alice = 0
    bob = 0

    for i, c in enumerate(sorted(cards, reverse=True)):
        if i == 0 or i % 2 == 0:
            alice += c
        else:
            bob += c

    print(alice - bob)


if __name__ == '__main__':
    main()


# Example run
# Input:
-563
56
# Output:
56
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
Alice = 0
Bob = 0
i = 0
for i in range(0,N,2):
    Alice += a[i]
    if i+1 >= N:
        break
    Bob += a[i+1]
print(Alice - Bob)

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


# Example run
# Input:
-20238871
43064
# Output:
43064
# 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:
    for j in range(int((n - 1)/2)):
        alice.append(a[2*j])
        bob.append(a[2*j + 1])
    alice.append(a[n - 1])
else:
    alice = a
#
alice_total = sum(alice)
bob_total = sum(bob)
ans = alice_total - bob_total
#
print(ans)


# Example run
# Input:
-1643990
363865392
# Output:
0
#n , m , l = map(int , input().split())

# list_n = list(map(int , inpuut().split()))<Paste>

#n = input()
# list = [input() for i in range(N)

#list = [[i for i in range(N)] for _ in range(M)]


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

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


# Example run
# Input:
-185
-2938
# Output:
-2938
N=int(input())
a = [int(i) for i in input().split()] 
a.sort()
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:
486937758
-9490166
# Output:
-9490166
N = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
Alice = [a[i] for i in range(N) if i % 2 == 0]

print(sum(Alice) * 2 - sum(a))

# Example run
# Input:
-69520
-73864104
# Output:
73864104
N = int(input())
card = list(map(int,input().split()))

card.reverse()

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

print(alice - bob)

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

goukei = 0

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

for i in range(0,len(a),2):
	goukei = goukei + (a[i] - a[i + 1])
#	print(a[i],a[i+1])
print(goukei)

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


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


# Example run
# Input:
-1
-3439167
# Output:
-3439167
input()
seq = sorted((int(x) for x in input().split()), reverse=True)
alice = sum(seq[::2])
bob = sum(seq[1::2])
print(alice - bob)

# Example run
# Input:
4-{,oH
243
# Output:
243
N = int(input())
a = list(map(int, input().split()))

cards = sorted(a, reverse=True)
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:
-450
139
# Output:
0
from typing import List


def answer(n: int, a: List[int]) -> int:
    alice = 0
    bob = 0

    a.sort(reverse=True)
    for i in range(0, len(a), 2):
        alice += a[i]
    for j in range(1, len(a), 2):
        bob += a[j]

    return abs(alice - bob)


def main():
    n = int(input())
    a = list(map(int, input().split()))
    print(answer(n,a))


if __name__ == '__main__':
    main()


# Example run
# Input:
9386
10
# Output:
10
from collections import deque

N = int(input())
a_list = sorted(list(map(int, input().split(' '))))

score_list = [0] * 2

available_cards = deque(a_list)

while len(available_cards) != 0:
    score_list[0] += available_cards.pop()
    try:
        score_list[1] += available_cards.pop()
    except:
        break

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


# Example run
# Input:
-1596917
-2
# Output:
-2
N = int(input())
a = input().split()
a = [int(s) for s in a]
a.sort()
a.reverse()

alice = 0
bob = 0

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

print(alice - bob)


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

alice = 0
bob = 0
A = sorted(A)[::-1]
for i, a in enumerate(A):
    if i % 2 == 0:
        alice += a
    else:
        bob += a
print(alice - bob)


# Example run
# Input:
129345041
471
# Output:
471
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:
1
-124978655
# Output:
-124978655
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:
-6163826
139893
# Output:
139893
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:
-194
-122062265
# Output:
0
n = int(input())
a = list(map(int, input().split()))
ans = 0

a.sort(reverse=True)
a_sum = sum(a[0:len(a):2])
b_sum = sum(a[1:len(a):2])

ans = a_sum-b_sum

print(ans)

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

# Example run
# Input:
-237211342
-8201172
# Output:
8201172
n = int(input())
l = list(map(int, input().split()))
Alice, Bob = 0, 0
for turn in range(0, n-1):
    if len(l) != 0:
        Alice += max(l)
        l.remove(max(l))
    if len(l) != 0:
        Bob += max(l)
        l.remove(max(l))
print(Alice-Bob)

# Example run
# Input:
-48
465
# Output:
0
def resolve():
    N = int(input())
    an = sorted([int(n) for n in input().split()], reverse=True)

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


if __name__ == '__main__':
    resolve()

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


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

a_p = 0
b_p = 0

for i in range(N):
    m = max(alist)
    if i%2 == 0:
        a_p += m
        alist[alist.index(m)] = 0
    else:
        b_p += m
        alist[alist.index(m)] = 0
print(a_p - b_p)

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

# Example run
# Input:
-5
-64
# Output:
0
n = int(input())
a = list(map(int, input().split()))
p = [0,0]

for i in range(n):
    p[i%2] += max(a)
    a.remove(max(a))
print(p[0]-p[1])


# Example run
# Input:
-347
-3339504
# Output:
0
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:
-58138
-607
# Output:
0
N = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
alice = 0
bob = 0
for i, el in enumerate(a):
    if i % 2 == 0:
        alice += el
    else:
        bob += el
print(alice - bob)

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

# Example run
# Input:
0
605260
# 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:
-264371717
10366
# Output:
10366
a = int(input())  
b = input()  
b = map(int, b.split())
print(type(b))
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:
-3753932
42339391
# Output:
<class 'map'>
42339391
n=int(input())
a=sorted(map(int,input().split()))

A=0
B=0

for i in range(n):
 if i%2 ==1:
  A += a[i]
 else:
  B += a[i]

print(A-B)

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

alice = 0
bob = 0
is_bob_turn = 0

for _ in range(len(a)):
  if not is_bob_turn:
    is_bob_turn = 1
    alice += max(a)
    del a[a.index(max(a))]
  else:
    is_bob_turn = 0
    bob += max(a)
    del a[a.index(max(a))]
print(alice-bob)

# Example run
# Input:
-56661351
981571
# Output:
981571
N = int(input())

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

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

al = sum([a for i,a in enumerate(a_list) if i%2==0])
bo = sum([a for i,a in enumerate(a_list) if i%2==1])

print(al-bo)

# Example run
# Input:
-640183291
155287
# Output:
155287
N = int(input())
Ai = list(map(int, input().split()))
Ai.sort(reverse=True)

score_a = 0
score_b = 0
for i in range(N):
    if i % 2 == 0:
        score_a += Ai[i]
    else:
        score_b += Ai[i]
print(score_a - score_b)


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

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

A = 0
B = 0
while len(a) > 0:
  A += max(a)
  a.remove(max(a))
  if len(a) > 0:
    B += max(a)
    a.remove(max(a))
  
print(A-B)

# Example run
# Input:
-5024207
-2147483648
# Output:
-2147483648
N = int(input())
A = [int(x) for x in input().split()]
A = sorted(A, reverse=True)
a = 0
b = 0
for i in range(N):
    if i%2==0:
        a+=A[i]
    else:
        b += A[i]
print(a-b)

# Example run
# Input:
-7467726
1372619017
# Output:
0
n = int(input())
a = sorted(list(map(int,input().split())))
a.reverse()
Alice = []
Bob = []
for i,p in enumerate(a):
    if i % 2 == 0:
        Alice.append(p)
    else:
        Bob.append(p)
print (sum(Alice) - sum(Bob))

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


# Example run
# Input:
8\G<E[
10077143
# Output:
10077143
N = int(input())
A =[i for i in map(int,input().split())]
A = sorted(A,reverse=True)
Alice = 0
Bob = 0
while len(A) != 0:
    Alice += int(A.pop(0))
    if len(A) == 0:
        break
    else:
        Bob += int(A.pop(0))

print(Alice - Bob)

# Example run
# Input:
86342186
37777
# Output:
37777
N = int(input())
lst = [int(i) for i in input().split()]
a = 0
b = 0
for i in range(N):
    if i % 2 == 0:
        a += max(lst)
    else:
        b += max(lst)
    lst.remove(max(lst))
print(a - b)


# Example run
# Input:
-114
-473
# Output:
0
def main():
    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)


if __name__ == '__main__':
    main()

# Example run
# Input:
869
8
# Output:
8
# coding: utf-8
# Your code here!
num = int(input())
s = sorted(list(map(int,input().split())),reverse=True)
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:
-64
-26729193
# Output:
-26729193
# https://atcoder.jp/contests/abc088/tasks/abc088_b

import itertools
import collections
import bisect

def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort(reverse=True)

    a_sum = sum([A[a] for a in range(0, len(A), 2)])
    b_sum = sum([A[a] for a in range(1, len(A), 2)])
    print(a_sum - b_sum)


if __name__ == '__main__':
    main()


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

print(ans)


# Example run
# Input:
-7038374
-6
# Output:
0
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))
    if len(A) == 0:
        break

print(Alice-Bob)

# Example run
# Input:
-74270783
2147483647
# Output:
2147483647
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:
-2777
-504
# Output:
0
a = int(input()) 
b = list(input().split())
c = [int(i) for i in b]
d = sorted(c, reverse=True)
Alice, Bob = 0, 0
for j in range(a):
  if j % 2 == 0:
    Alice += d[j]
  else:
    Bob += d[j]
diff = Alice - Bob
print(diff)

# Example run
# Input:
-746
-63
# Output:
0
n = int(input())
card = list(map(int,input().split()))

card.sort(reverse=True)

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:
-7038374
-6
# Output:
0
n=int(input())
l=[int(i) for i in input().split()]
l.sort()
l.reverse()
a=sum(l[0::2])
b=sum(l[1::2])
print(a-b)

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

# Example run
# Input:
-728818981
-2811762
# Output:
-2811762
# -*- coding: utf-8 -*-

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

A = 0
B = 0
if n%2 == 0:
    r = int(n/2)
    for i in range(0,r):
        A += max(a)
        a.remove(max(a))
        B += max(a)
        a.remove(max(a))
else:
    r = int(n/2)
    for i in range(0,r):
        A += max(a)
        a.remove(max(a))
        B += max(a)
        a.remove(max(a))
    A += max(a)

print(A-B)

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

A, B = 0, 0

a.sort()
a.reverse()
for i, j in enumerate(a):
    if i % 2 == 0:
        A += j
    else:
        B += j
        
print(A - B)

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

# Example run
# Input:
xWAS`~
-255155
# Output:
-255155
N = int(input())
numbers = list(map(int, input().split()))
Alice_point = 0
Bob_point = 0

numbers.sort(reverse=True)

while True:
    try:
        Alice_point += numbers[0]
        Bob_point += numbers[1]
        numbers.remove(numbers[0])
        numbers.remove(numbers[0])
    except IndexError:
        break

print(Alice_point - Bob_point)


# Example run
# Input:
-70037
-1002
# Output:
-1002
#!/usr/local/bin/python3
# https://atcoder.jp/contests/abc088/tasks/abc088_b

_ = int(input())
A = sorted(list(map(int, input().split())))[::-1]

ans = 0
for i, a in enumerate(A):
    if i % 2 == 0:
        ans += a
    else:
        ans -= a

print(ans)


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

a.sort()
a.reverse()

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

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

# Example run
# Input:
-158606
-156960
# Output:
-156960
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:
-124978655
-23909
# Output:
0
n=int(input())
a=[int(i)for i in input().split()]
a.sort()
alice=0
bob=0
for i in range(n):
    if i%2==0:
        alice+=a.pop(-1)
    else:
        bob+=a.pop(-1)
print(alice-bob)

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

a.sort()
alice = 0
bob = 0
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:
-525602
42329671
# Output:
0
N=int(input())
a=list(map(int,input().split()))
a=sorted(a,reverse=True)
A,B=[],[]
for i in range(N):
  if i % 2 == 0:
    A.append(a[i])
  else:
    B.append(a[i])
print(sum(A)-sum(B))

# Example run
# Input:
-192707
237144
# Output:
0
N=int(input()) 
a = list(map(int, input().split()))
sum=0
a.sort()
a.reverse()
if(N>1):
  for i in range(0,N-1,2):
    sum=sum+a[i]-a[i+1]
else:
  sum=a[0]
print(sum)

# Example run
# Input:
-18771736
12
# Output:
12
n = int(input())
a_lst = sorted(list(map(int,input().split())),reverse=True)

bob = 0
alice = 0

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

print(alice-bob)

# Example run
# Input:
89
-39645188
# Output:
-39645188
n = int(input())
li = sorted(map(int,input().split()),reverse=True)
ans = sum(li[::2]) - sum(li[1::2])
print(ans)

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


# Example run
# Input:
-1
-3439167
# Output:
-3439167
N = int(input())
a = map(int, input().split())
a = sorted(a, reverse=True)
i = 0
s = 0
for x in a:
    if i % 2 == 0:
        s += x
    else:
        s -= x
    i += 1
print(s)

# Example run
# Input:
9
313685
# Output:
313685
N = int(input())
a = [int(i) for i in input().split()]

a.sort()
a = a[::-1]

A = a[::2]
B = a[1::2]

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


# Example run
# Input:
-7
9186
# Output:
9186
n = int(input())

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


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

# Example run
# Input:
-562
4
# Output:
4
num = int(input())

alice = 0
bob = 0
cards = list(map(int,input().split()))
for i in range(1,num+1):
    
    if i % 2 == 1:
        alice += max(cards)
        cards.remove(max(cards))
    else:
        bob += max(cards)
        cards.remove(max(cards))

ans = alice - bob
print(ans)
        

# Example run
# Input:
-436344399
-83
# Output:
0
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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:
142
-591
# Output:
-591
N = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
print(sum(a[::2]) - sum(a[1::2]))


# Example run
# Input:
224
332914
# Output:
332914
dat =list(input().split())

for i in dat:
	i = int(i)

dat.sort(reverse=True)

asum = 0
bsum = 0
sum = 0

for i in range(len(dat)):
     sum = dat[i]
		
print(sum)

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

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

# Example run
# Input:
-30
-54634663
# Output:
-54634663
n = input()
num = [i for i in map(int,input().split(" "))]

num.sort(reverse=True)

A = 0
B = 0
t=0
print(num)
for i in num:
    if t%2==0:
        A+=int(i)
    else:
        B+=int(i)
    t+=1
print(A-B)


# Example run
# Input:
~_p|DP\
-29588
# Output:
[-29588]
-29588
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:
-33958
1593280440
# Output:
0
N = int(input())

a = list(map(int, input().split()))
Alice = 0
Bob = 0

# print(a)

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

print(Alice -Bob)




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

cnt = 0
plmn = 1
for i in a:
    cnt += plmn * i
    plmn *= -1

print(cnt)

# Example run
# Input:
320
1510792572
# Output:
1510792572
num = int(input())
input_str_list = input().split()
input_list = []
for i in input_str_list:
	input_list.append(int(i))
input_list.sort(reverse=True)

A = 0
B = 0
A_list = input_list[::2]
B_list = input_list[1::2]
for i in A_list:
	A += i
for i in B_list:
	B += i
print(A-B)
	

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

# Example run
# Input:
-49093496
-1
# Output:
-1
# -*- coding: utf-8 -*-

n = int(input())
a = sorted(list(map(int, input().split())), 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:
-1836
-168854
# Output:
0
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:
-30547349
2147483647
# Output:
0
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
alice = sum([a[i] for i in range(n) if i % 2 == 0])
bob = sum([a[i] for i in range(n) if i % 2 == 1])
print(alice-bob)

# Example run
# Input:
-117864
-38181262
# Output:
0
n = int(input())
a_list = list(map(int, input().split()))
print(a_list)

a_list.sort(reverse = True)
alice_sum = 0
bob_sum = 0
for i in range(len(a_list)):
    if i % 2 == 0:
        alice_sum += a_list[i]
    else:
        bob_sum += a_list[i]

print(alice_sum - bob_sum)

# Example run
# Input:
3615919
-3550
# Output:
[-3550]
-3550
def solve(a_list):
  alice_sum = 0
  bob_sum = 0
  a_list.sort()
  while True:
    if a_list == []:
      break
    alice_sum += a_list.pop()
    if a_list == []:
      break
    bob_sum += a_list.pop()
  
  return alice_sum - bob_sum

def main():
  N = int(input())
  a_list = list(map(int, input().strip().split()))
  print(solve(a_list))

if __name__ == '__main__':
  main()


# Example run
# Input:
104392
12824734
# Output:
12824734
n = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
alc = 0
bb = 0
for i in range(0, n, 2):
    alc += A[i]
for j in range(1, n, 2):
    bb += A[j]
print(alc - bb)

# Example run
# Input:
-5271130
19
# Output:
0