Felix6326727/beyond-accuracy-code-comprehension huggingface dataset:
N = int(input())
A = list(map(int,input().split(" ")))
# A.sort()
A = sorted(A,reverse=True)
print(A)
a_sum = 0
b_sum = 0
for i in range(len(A)):
    if i%2==0:
        a_sum+= A[i]
    else:
        b_sum += A[i]

print(a_sum-b_sum)

# Example run
# Input:
8131
1813543
# Output:
[1813543]
1813543
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:
+CP)0CA
43251559
# Output:
[43251559]
43251559
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:
-52564348
-7737
# Output:
0
# -*- coding: utf-8 -*-

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

    a.sort(reverse = True)
    ans = 0
    for i, num in enumerate(a):
        if i % 2 == 0:
            ans += num
        else:
            ans -= num

    print(ans)

if __name__ == '__main__':
    main()


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

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

print(a-b)




# Example run
# Input:
8
-2222
# Output:
-2222
N=int(input())

x_list=list(map(int,input().split()))
x_list=sorted(x_list)

a,b=0,0

for i in range(N):
    if((i+1)%2!=0):
        a+=x_list[i]
    else:
        b+=x_list[i]

print(a-b)

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

a.sort()
a.reverse()
print(sum([a[i] if i % 2 == 0 else -a[i] for i in range(n)]))


# Example run
# Input:
-147
-3225
# Output:
0
n = int(input())
alst = list(map(int, input().split()))
alst.sort(reverse = True)
ans = 0
pm = 1
for a in alst:
    ans += a * pm
    pm *= -1
print(ans)

# Example run
# Input:
377
-10
# Output:
-10
n=int(input())
a=sorted(list(map(int,input().split())),reverse=True)
b=0
for i in range(n):
  b+=a[i]*(-1)**i
print(b)

# Example run
# Input:
-347
-3339504
# 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:
-153163
-32942311
# Output:
-32942311
# -*- coding: utf-8 -*-
a = int(input())  # Nを入力
b = input()  # a1,a2...anを入力
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:
-101281970
-210
# Output:
<class 'map'>
-210
N=int(input())
numbers=list(map(int,input().split()))
for i in range(1,N):
    for k in range(i):
        if numbers[k]<numbers[i]:
            temp=numbers[k]
            numbers[k]=numbers[i]
            numbers[i]=temp
            break
print(numbers)
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)
print(Alice-Bob) 

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

# Example run
# Input:
-1
-3439167
# Output:
3439167
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:
-7038374
-6
# Output:
0
N = int(input())
l = list(map(int, input().split()))
L = sorted(l, reverse = True)
A = 0
B = 0
for i in range(N):
  if i % 2 == 0:
    A += L[i]
  else:
    B += L[i]
print(A - B)

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

# Example run
# Input:
-1
-221907
# Output:
-221907
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:
-4868286
-104837
# Output:
0
n=int(input())
cards=list(map(int,input().split()))
cards.sort(reverse=True)

alice=[]
bob=[]

if len(cards)%2==0:
    while len(cards)>1:
        alice.append(cards[0])
        del cards[0]
        bob.append(cards[0])
        del cards[0]
else:
    while len(cards)>1:
        alice.append(cards[0])
        del cards[0]
        bob.append(cards[0])
        del cards[0]

    alice.append(cards[0])

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

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

def quicksort(array):
    if len(array) < 2:
        return(array)
    else:
        pivot = array[0]
        less = [i for i in array[1:] if i <= pivot]
        greater = [i for i in array[1:] if i > pivot]

        return quicksort(greater) + [pivot] + quicksort(less)


sorted_a = quicksort(a)
alice = []
bob = []
for i in range(len(sorted_a)):
    if i % 2 == 0:
        alice.append(sorted_a[i])
    else:
        bob.append(sorted_a[i])
print(sum(alice) - sum(bob))


# Example run
# Input:
-596233
0
# Output:
0
input()
li = list(map(int, input().split()))
li.sort(reverse=True)
alice = [i for index,i in enumerate(li) if index % 2 == 0]
print(alice)

# Example run
# Input:
u'h
-3433
# Output:
[-3433]
def main():
    N = int(input())
    A = list(map(int, input().split()))

    sort_A = sorted(A, reverse=True)
    alice = 0
    bob = 0
    for i, a in enumerate(sort_A):
        if i % 2 == 0:
            alice += a
        else:
            bob += a

    print(alice - bob)


main()

# Example run
# Input:
1761864
0
# Output:
0
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:
-13
7381
# Output:
0
N = int(input())
a = list(map(int,input().split()))
ans = 0
a = sorted(a)
a = a[::-1]
for i in range(N):
    if i % 2 == 0:
        ans += a[i]
    else:
        ans -=a[i]
print(ans)

# Example run
# Input:
-330
-2503
# Output:
0
n = int(input())
a = list(map(int, input().split()))
a.sort()
b = a[0::2]
c = a[1::2]
print(abs(sum(b)-sum(c)))

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

Alice = 0
Bob = 0
A.sort(reverse=True)

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



# Example run
# Input:
-4589549
165350
# Output:
165350
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:
-54266464
-274078593
# Output:
0
input()
(*a,) = sorted(map(int, input().split()), reverse=True)
print(sum(a[::2]) - sum(a[1::2]))

# Example run
# Input:
_y3ny`DHI
2147483647
# Output:
2147483647
N = int(input())

Alice = []
Bob = []

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

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

while len(a) > 0:
    Alice.append(a.pop(0))
    Bob.append(a.pop(0))

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

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

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

# Example run
# Input:
-812896393
-97075663
# Output:
0
# -*- coding: utf-8 -*-
N = int(input())
a = list(map(int, 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:
-1138
-22588477
# Output:
0
n = int(input())

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

a = 0
b = 0

A = list(reversed(sorted(A)))

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

# Example run
# Input:
-28797
607509343
# Output:
0
N = int(input())
A = list(map(int,input().split()))
B = []
for i in range(0,N,2):
  B.append(A[i])
print(abs(sum(A)-sum(B)*2))


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

# Example run
# Input:
-2540
-1836
# Output:
1836
N = int(input()) 
a = sorted(list(map(int, input().split())))[::-1]
f = int(0)
Ali = int(0)
Bob = int(0)

for i in range(N):
  if f == 0:
    Ali = Ali + a[0]
    del a[0]
    f = 1
  else:
    Bob = Bob + a[0]
    del a[0]
    f = 0
print(Ali-Bob)


# Example run
# Input:
-5930
-31
# 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:
-129
-5403886
# Output:
0
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
print(sum(a[::2]) - sum(a[1::2]))

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

# Example run
# Input:
-7
-7737
# Output:
-7737
N=int(input())
a=list(map(int,input().split()))
na=sorted(a,reverse=True)
Alice=0
Bob=0

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

print(Alice-Bob)

# Example run
# Input:
-47028
-30375
# Output:
0
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    a = f()

    a = sorted(a, reverse = True)

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

solve()


# Example run
# Input:
-408326
-7191
# Output:
0
cordcount = int(input())

n = input()
alice = 0
bob = 0

lis = n.split(" ")
x = sorted(lis)

print(x)

alice = x[::-2]
bob = x[0:-1:2]
print(alice,bob)

total = 0
tot = 0

for i in alice:
    total = int(i)+total

for n in bob:
    tot = int(n)+tot
print(total-tot)

# Example run
# Input:
56
1049999
# Output:
['1049999']
['1049999'] []
1049999
N = int(input())
cards = sorted(map(int, input().split()), reverse=True)
A, B = sum(cards[0::2]), sum(cards[1::2])
print(str(A-B))

# Example run
# Input:
-812896393
-97075663
# Output:
-97075663
def main():
    N = int(input())
    a = sorted([int(x) for x in input().split(" ")], reverse=True)
    Alice = sum([x for i, x in enumerate(a) if i % 2 == 0])
    Bob = sum([x for i, x in enumerate(a) if i % 2 == 1])
    print(Alice-Bob)


if __name__ == '__main__':
    main()


# Example run
# Input:
-436344399
-83
# Output:
-83
# -*- coding: utf-8 -*-

N = int(input())
a = list(map(int, input().split(" ")))
a.sort(reverse=True)
S = sum(a)
s = 0
for i in range(0, N, 2):
  s = s + a[i]

print(s - (S - s))

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

# Example run
# Input:
57223618
-62350830
# Output:
-62350830
N=int(input())
cards = list(map(int, input().split()))
cards.reverse()
Alice=sum(cards[0:N:2])
Bob=sum(cards[1:N:2])
print(Alice-Bob)

# Example run
# Input:
805965556
-19
# Output:
-19
n = int(input())
list = [int(x)for x in input().split()]
list.sort(reverse=True)
a = 0
b = 0
for i in range(n):
  if i %2 ==0:
    a += list[i]
  else:
    b += list[i]

print(a-b)

# Example run
# Input:
-7517
134
# Output:
0
def solve():
    N = int(input())
    a = list(map(int, input().split()))
    a.sort(reverse=True)    #  降順で整列

    score_of_Alice = 0
    score_of_Bob = 0

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

    print(score_of_Alice - score_of_Bob)

solve()

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

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

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

alice = sorted(a)[::2]
bob = sorted(a)[1::2]

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

# Example run
# Input:
-143891
-195933
# Output:
195933
N = int(input())
a = map(int, input().split())
a_sort = sorted(a, reverse=True)
Alice = 0
Bob = 0
for i in range(N):
    if i%2==0:
        Alice += a_sort[i]
    else:
        Bob += a_sort[i]
print("{}".format(Alice-Bob))

# Example run
# Input:
-24166826
-802253
# Output:
0
from collections import deque

n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
a = deque(a)
alice = []
bob = []
for i in range(len(a)):
    if i % 2 == 0:
        alice.append(a.popleft())
    else:
        bob.append(a.popleft())
print(sum(alice) - sum(bob))

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

alice = 0
bob = 0
for i in range(0, N):
    m = max(A)
    if i % 2 == 0: 
        alice += m
    else:
        bob += m
    A.remove(m)
print(alice-bob)

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

# Example run
# Input:
1267176863
68
# Output:
68
def main():
  size = input()
  a = list(map(int, input().split()))
  a = merge_sort(a)
  
  alice_res = 0
  bob_res = 0
  
  for i in range(len(a)):
    if i%2 == 0:
      alice_res += a[i]
    else:
      bob_res += a[i]
 
  print(alice_res-bob_res)
  
 
def merge_sort(array):
  if len(array)<=1:
    return array
  
  spl_size = len(array)//2
  
  left_list = merge_sort(array[:spl_size])
  right_list = merge_sort(array[spl_size:])
  
  return merge_list(left_list, right_list)
 
 
def merge_list(left_list, right_list):
  left_index = 0
  right_index = 0
  sorted_list = []
  
  while left_index<len(left_list) and right_index<len(right_list):
    if left_list[left_index] < right_list[right_index]:
      sorted_list.append(right_list[right_index])
      right_index+=1
    else:
      sorted_list.append(left_list[left_index])
      left_index+=1
      
  if left_index == len(left_list):
    sorted_list.extend(right_list[right_index:])
  if right_index == len(right_list):
    sorted_list.extend(left_list[left_index:])
      
  return sorted_list
    
                          
main()

# Example run
# Input:
is]
-5992
# Output:
-5992
# 2020-08-30, Sun

n = int(input())
lis = sorted(list(map(int, input().split())), reverse=True)
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:
-63
-213058
# Output:
-213058
n = int(input())

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

alice = []

bob = []

for i in range(n):
	alice.append(max(card))
	del card[card.index(max(card))]
	if card == []:
		break
	bob.append(max(card))
	del card[card.index(max(card))]
	if card == []:
		break
        
print(sum(alice) - sum(bob))

# Example run
# Input:
757115353
-7698469
# Output:
-7698469
N=int(input())
L=[int(i) for i in input().split()]
L.sort(reverse=True)
a=0
b=0
for i in range(N):
  if i%2==0:
    a+=L[i]
  else:
    b+=L[i]
print(a-b)

# Example run
# Input:
-224231
-640183291
# Output:
0
n = int(input())
x = sorted(map(int,input().split()))
x.reverse()
a = 0
b = 0
for i in range(n):
    if i%2==0:
        a+=x[i]
    else:
        b+=x[i]
print(a-b)

# Example run
# Input:
-117864
-38181262
# Output:
0
N = int(input())
A = [int(a) for a in input().split()]
A = sorted(A)

alice = 0
bob = 0

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

print(alice - bob)

# Example run
# Input:
-163
4554
# Output:
0
N = int(input())
As = list(map(int, input().split()))

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

# Example run
# Input:
-497
-15860207
# Output:
-15860207
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

N = int(input())
a = readints()
# print(a)
aa = sorted(a, reverse=True)
print(aa)
x = 0
for i in range(len(a)):
    if i % 2 == 0:
        x += aa[i]
    else:
        x -= aa[i]
print(x)


# Example run
# Input:
-4868286
-104837
# Output:
[-104837]
-104837
n = int(input())
a = sorted(map(int,input().split()))[::-1]

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

# Example run
# Input:
-133790981
215616622
# Output:
215616622
n = int(input())
a = [ int(i) for i in input().split() ]
a = sorted(a)[::-1]
ans = 0
for i in range(len(a)):
    if i % 2 == 0:
        ans += a[i]
    else:
        ans -= a[i]
print(ans)


# Example run
# Input:
-158606
-156960
# Output:
-156960
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:
68688
-8132114
# Output:
-8132114
n = int(input())
cards_list = list(map(int,input().split()))
cards_list.sort()
cards_list.reverse()
sum_alice = 0
sum_bob = 0
turn = 0

for val in cards_list:
    if turn == 0:
        sum_alice += val
        turn = 1
    else:
        sum_bob += val
        turn = 0

print(sum_alice-sum_bob)

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

a.sort(reverse=True)
score_of_alice, score_of_bob = 0, 0
for i in range(n):
    score = a.pop(0)
    if i % 2 == 0:
        score_of_alice += score
    else:
        score_of_bob += score

print(score_of_alice - score_of_bob)


# Example run
# Input:
-24166826
-802253
# 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:
0
227
# Output:
0
# -*- coding: utf-8 -*-

#N枚のカードがあり、i枚目のカードにはaiという数が書かれています。
#AliceとBobはこれらのカードを使ってゲームを行います。ゲームでは2人が交互に1枚ずつカードを取っていきます。Aliceが先にカードを取ります。
#2人が全てのカードを取った時ゲームは終了し、取ったカードの数の合計がその人の得点になります。2人とも自分の得点を最大化するように最適戦略を取った時、AliceはBobより何点多く獲得できるかを求めてください。

#1<=N<=100, 1<=ai<=100, 入力は整数
#数値例 N=3, a=(2,7,4), Answer: 5

N = int(input())
numbers = list(map(int, input().split()))
Alice_point = 0
Bob_point = 0

numbers.sort()
print(numbers)

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

print(Alice_point - Bob_point)

# Example run
# Input:
332914
793
# Output:
[793]
793
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:
-1
-221907
# Output:
-221907
N = int(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
  else:
    Bob += a
    
print(Alice - Bob)

# Example run
# Input:
-3225
-5024207
# Output:
-5024207
N = int(input())
Alice_total = 0
Bob_total = 0
card_list = input().split()
card_list = [int(n) for n in card_list]
card_list.sort(reverse =True)

for i in range(0,N,2):
    Alice_total += card_list[i]

for i in range(1,N,2):
    Bob_total += card_list[i]

print(Alice_total - Bob_total)

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

a = 0
b = 0

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

print(a - b)

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

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


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

a.sort(reverse=True)
Alice = 0
Bob = 0

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

Bob = sum(a) - Alice
ans = Alice - Bob

print(ans)

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

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

# Example run
# Input:
7qRN-`
-1
# Output:
-1
n = int(input())
l = list(map(int, input().split()))
a = 0
b = 0

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

# Example run
# Input:
-24
-35784
# Output:
0
n = int(input())
l = sorted(list(map(int, input().split())), reverse = True)
ans = 0
for i in range(n // 2):
    ans += l[i] - l[n - 1 - i]
if n & 1:
    ans += l[n // 2]
print(ans)


# Example run
# Input:
-39645188
-202
# Output:
0
n = int(input())

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

a_point = 0
b_point = 0
for i in range(len(arr)):
    if i % 2 == 0:
        a_point += arr[i]
    else:
        b_point += arr[i]

print(a_point - b_point)

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

# Example run
# Input:
197383
-39547
# Output:
-39547
n = int(input()) 
k = list(map(int, input().split()))
k.sort()
k = k[::-1]
s = 0
for i in range(n):
    if i%2==0:
        s+=k[i]
    else:
        s-=k[i]
print(s)

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

# Example run
# Input:
14319043
15927431
# Output:
15927431
N=int(input())
a_input_list=input().split(' ')
a_num_list=[]
for a in a_input_list:
  a_num_list.append(int(a))

a_num_list.sort()
a_num_list.reverse()

bob=0
allice=0

counter=0
for a in a_num_list:
  if counter%2==0:
    allice+=a
  else:
    bob+=a
  counter+=1

print(allice-bob)

# Example run
# Input:
-960
1892351448
# Output:
1892351448
# ABC 088: B – Card Game for Two
n = int(input())
a = [int(s) for s in input().split()]
a.sort(reverse = True)
print(sum(a[0::2]) - sum(a[1::2]))

# Example run
# Input:
142
-30
# Output:
-30
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:
0
331737
# Output:
331737
N = int(input())
nlist = [int(i) for i in input().split()]
nlist.sort(reverse = True)
print(sum(nlist[::2]) - sum(nlist[1::2]))

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

a.sort()
a.reverse()

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


# Example run
# Input:
-207
386945
# Output:
0
n = int(input())
cards = sorted(list(map(int, input().split())), 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:
-358903
-4422
# Output:
0
n=int(input())
a=sorted(list(map(int,input().split())))
ans=0
for i in range(n):
  ans+=a[n-1-i]*(-1)**i
print(int(ans))

# Example run
# Input:
-230914
-246934
# Output:
0
n = int(input())
a = sorted(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:
-18758
470
# Output:
0