Felix6326727/beyond-accuracy-code-comprehension huggingface dataset:
N = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
Alice = a[1::2]
Bob = a[::2]
print(sum(Bob)-sum(Alice))

# Example run
# Input:
945
0
# Output:
0
N = int(input())
A =[i for i in map(int,input().split())]
A = sorted(A,reverse=True)
print(A)
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:
-33958
1593280440
# Output:
[1593280440]
1593280440
# -*- coding: utf-8 -*-

n = int(input())
a = [int(s) for s in input().split(" ")]
a.sort()
alice = sum(a[-1::-2])
bob = sum(a[-2::-2])

print(alice - bob)

# Example run
# Input:
58900
945
# Output:
945
N = int(input())
A = sorted(map(int, input().split()), reverse=True)

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


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

a = sorted(list(A), reverse=True)
print(sum(a[0::2]) - sum(a[1::2]))


# Example run
# Input:
-2
-497
# Output:
-497
n = int(input())
a = sorted([int(x) for x in input().split()], reverse = True)

alice, bob = 0, 0
for i in range(n):
    if i & 1:
        bob += a[i]
    else:
        alice += a[i]

print(alice-bob)

# Example run
# Input:
-104837
-69520
# Output:
0
N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)

Alice=A[::2]
Bob=A[1::2]
print(sum(Alice)-sum(Bob))

# Example run
# Input:
-28418
-29
# Output:
-29
def main():
    n = int(input())
    a = list(map(int, input().split()))
    x, y = 0, 0
    for i, z in enumerate(sorted(a)):
        if i % 2 == (n-1) % 2:
            x += z
        else:
            y += z
    print(x - y)


if __name__ == '__main__':
    main()


# Example run
# Input:
-337
3782763
# Output:
3782763
N = int(input())
a = list(map(int, input().split()))
Alice = []
Bob = []
while a != []:
    get = max(a)
    Alice.append(get)
    a.remove(get)
    if a != []:
        get = max(a)
        Bob.append(get)
        a.remove(get)
print(sum(Alice) - sum(Bob))

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

# Example run
# Input:
P'#_R(4
-696
# Output:
-696
n = int(input())
a_list = list(map(int, input().split()))
alice = 0
bob = 0
tmp_value = 0
tmp_index = 0

while len(a_list) > 0:
    for i in range(len(a_list)):
        if tmp_value < a_list[i]:
            tmp_value = a_list[i]
            tmp_index = i
    alice += tmp_value
    del a_list[tmp_index]
    tmp_value, tmp_index = 0, 0
    if len(a_list) == 0:
        break
    for k in range(len(a_list)):                                                                                  
        if tmp_value < a_list[k]:
            tmp_value = a_list[k]
            tmp_index = k
    bob += tmp_value
    del a_list[tmp_index]

print(str(alice - bob))


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

# Example run
# Input:
203
228
# Output:
228
def resolve():
    # 整数 1 つ
    n = int(input())
    # 整数複数個
    # a, b, c = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    A = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    sumA=0
    sumB=0
    B = sorted(A, reverse=True)
    turnB = False

    for i in B:
        if turnB == False:
            sumA += i
            turnB = True
        else:
            sumB += i
            turnB = False

    print(int(sumA - sumB))


resolve()

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

a.sort(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:
-525059
89101055
# Output:
0
n = int(input())
arr = list(map(int, input().split()))

arr.sort(reverse=True)

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




# Example run
# Input:
212
-11989124
# Output:
-11989124
n=int(input())

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

c.sort(reverse=True)

alice = sum([c[i] for i in range(len(c)) if i%2==0])

print(2*alice-sum(c))

# Example run
# Input:
51856
15
# Output:
15
n=int(input())
a=list(map(int,input().split()))
alice=0
bob=0
a=sorted(a,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:
1267074
54504816
# Output:
54504816
input()
a=sorted(map(int,input().split()))[::-1]
print(sum(a[::2])-sum(a[1::2]))

# Example run
# Input:
HsGl9$>e
89
# Output:
89
# -*- coding:utf-8 -*-

N = int(input())
li_raw = input().split()
li = [int(j) for j in li_raw]

turn = 1
A = 0
B = 0

while li != []:
    max = 0
    for x in li:
        if x > max:
            max = x
    if turn == 1:
        A += max
    else:
        B += max
    li.remove(max)
    turn = -turn
print(A-B)


# Example run
# Input:
96
47
# Output:
47
n = int(input())
card = list(map(int,input().split()))

card.sort()

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

print(asum-bsum)

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

# Example run
# Input:
-56661351
981571
# Output:
0
N = int(input())
a = map(int, input().split())
b = sorted(list(a), reverse=True) + [0]
print(sum(b[i] - b[i + 1] for i in range(0, N, 2)))


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


# Example run
# Input:
-18991721
465
# Output:
465
N = int(input())
a = sorted(list(map(int,input().split())))
a = a[::-1]

A = sum(a[0::2])
B = sum(a[1::2])

print(A-B)

# Example run
# Input:
-3753932
42339391
# Output:
42339391
N = int(input())
cards = list(map(int, input().split()))
cards.sort()
alice, bob = 0, 0
while True:
    alice += cards.pop()
    if not cards:
        break
    bob += cards.pop()
    if not cards:
        break
print(alice - bob)

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

# Example run
# Input:
1
-4
# Output:
-4
n=int(input())
a=sorted(list(map(int,input().split())),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:
-1893070
10823
# Output:
0
N = input()
li = input().split()
li.sort(reverse=True)
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:
=,o|`N
-75
# Output:
-75
n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)

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

# Example run
# Input:
0
11
# Output:
11
N = int(input())
list_an = input().split()
list_an_int = [int(s) for s in list_an]

list_an_int.sort()
list_an_int.reverse()

print(list_an_int)
Alice_counter = 0
Bob_counter = 0

counter = 0
for i in range(N):
    if counter % 2 == 0:
        Alice_counter += list_an_int[i]
    else:
        Bob_counter += list_an_int[i]
    counter += 1
print(Alice_counter - Bob_counter)


# Example run
# Input:
-14
0
# Output:
[0]
0
# vim: fileencoding=utf-8


def main():
    n = int(input())
    li = list(map(int, input().split()))
    li.sort(reverse=True)
    a = sum(li[::2])
    b = sum(li[1::2])
    ans = a - b
    print(ans)


if __name__ == "__main__":
    main()


# Example run
# Input:
2
340981
# Output:
340981
n=int(input())
x = [int(i) for i in input().split()]
xx = sorted(x)
ans=0
aaa=0
if n%2==0:
  for i in range(n//2):
    ans+=xx[i*2+1]-xx[i*2]
  print(ans)
else:
  for i in range(n//2):
    ans+=xx[i*2+1]-xx[i*2]
  aaa=xx[n-1]-ans
  print(aaa)

# Example run
# Input:
-94404
174987
# Output:
0
n = int(input())
c_L = list(map(int,input().split()))

c_L.sort(reverse=True)

alice,bob = 0,0

for val in range(len(c_L)):
    if val %2==0:
        alice += c_L[val]
    else:
        bob += c_L[val]
print(alice-bob)


# Example run
# Input:
11306
-88868
# Output:
-88868
N = int(input())
 
if N%2 == 0:
  print(N/2)
else:
  print([N+1] / 2)

# Example run
# Input:
116
# Output:
58.0
# -*- coding: utf-8 -*-
"""
Created on Fri Jun 15 11:27:37 2018

@author: Yuya
"""

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:
        Bob += A[i]
    else:
        Alice += A[i]

print(Alice-Bob)

# Example run
# Input:
-1
10525264
# Output:
0
N = int(input())
X = [int(i) for i in input().split()]
X.sort(reverse=True)
ans = 0
for i in range(N):
    if i % 2 == 0:
        ans += X[i]
    else:
        ans -= X[i]
print(ans)


# Example run
# Input:
1
8030667
# Output:
8030667
N = int(input())
a = [int(x) for x in input().split()]

a.sort(reverse=True)                # カードを降順ソートして
alice = sum([i for i in a[0::2]])   # aliceは偶数番目を
bob = sum([i for i in a[1::2]])     # bobは奇数番目の総和を取得
print(alice - bob)

# Example run
# Input:
31946
-3122
# Output:
-3122
n = int(input())
al = list(map(int, input().split()))

a_s = sorted(al, reverse=True)

ali = 0
bob = 0
count = 0

for a in a_s:
    count += 1
    if count %2 != 0:
        ali += a
    else:
        bob += a

print(ali-bob)

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

A.sort()
A.reverse()

R = sum([a if i % 2 == 0 else -1 * a for i, a in enumerate(A)])
print(R)


# Example run
# Input:
-1628416575
-831
# Output:
-831
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:
2502
10
# Output:
10
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:
-213058
-83
# Output:
-83
n = int(input())
a = list(map(int, input().split()))

a.sort(reverse=True)

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


# Example run
# Input:
-27082
4083
# Output:
4083
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:
-264371717
10366
# Output:
10366
N = int(input())
a = sorted(list(map(int, input().split())))[::-1]
print(sum(a[0::2])-sum(a[1::2]))

# Example run
# Input:
10
-1
# Output:
-1
N = int(input())
a = list(map(int,input().split()))
a.sort(reverse = True)
A = []
for i in a[::2]:
    A.append(i)
print(sum(A)*2-sum(a))

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

# Example run
# Input:
431968623
3132478
# Output:
3132478
N = int(input())
a_list = list(map(int, input().split()))

sort_a_list = sorted(a_list)

alice = 0
bob = 0

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

print(alice - bob)

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

# Example run
# Input:
188355
130358
# Output:
130358
import math
N = int(input())
a = list(map(int, input().split()))
a.sort(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:
-299483
83
# Output:
0
N = input()
AL = list(map(int, input().split()))
AL.sort()
AL.reverse()
print(sum(AL[::2])-sum(AL[1::2]))

# Example run
# Input:
.s09
-1
# Output:
-1
# coding: utf-8
# Your code here!

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

Alice=0
Bob=0

A.sort()
A.reverse()

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

# Example run
# Input:
1552
113162947
# Output:
113162947
n = int(input())
a = list(map(int, input().split()))
a_min = min(a)
alice = 0
bob = 0
while max(a) != 0:
    alice += max(a)
    for i in range(len(a)):
        if a[i] == max(a):
            a[i] = 0
            break
    bob += max(a)
    for i in range(len(a)):
        if a[i] == max(a):
            a[i] = 0
            break
if alice > bob:
    print(alice-bob)
else:
    print(bob-alice)

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


# Example run
# Input:
-19127
431
# Output:
431
n = int(input())

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

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:
755
3485
# Output:
3485
N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
print(sum(A[0::2])*2-sum(A))

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

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

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

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

print(A_point - B_point)

# Example run
# Input:
5771
1038302991
# Output:
1038302991
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    N = int(input())
    A = list(sorted(list(map(int, input().split())), reverse=True))
    a, b = 0, 0
    for i in range(N):
        if i % 2 == 0:
            a += A[i]
        else:
            b += A[i]
    print(a - b)
    

if __name__ == '__main__':
    main()


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

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

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

a.sort(reverse=True)

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

print(alice - bob)

# Example run
# Input:
1648
107
# Output:
107
input()
print(sum(-k if i%2 else k for i,k in enumerate(sorted(map(int,input().split()),reverse=True))))

# Example run
# Input:
A{q_{
45718
# Output:
45718
n = int(input())
a = list(map(int, input().split()))

def heap_sort(arr_ref):
    def swap(arr, a, b):
        tmp = arr[a]
        arr[a] = arr[b]
        arr[b] = tmp
    arr = arr_ref
    arr_sorted = []
    if(len(arr) == 1):
        arr_sorted = arr
    elif(len(arr) == 2):
        if(len(arr) <= 2):
            if(arr[0] < arr[1]):
                swap(arr, 0, 1)
            arr_sorted = arr
    else:
        while(True):
            while(True):
                flag_swap = True
                for i in range(int(len(arr)/2)): #配列の一番最後の根まで
                    if((arr[i] < arr[i*2]) and (arr[i] < arr[i*2 + 1])):
                        if(arr[i*2] > arr[i*2 + 1]):
                            swap(arr, i, i*2)
                        else:
                            swap(arr, i, i*2 + 1)
                    elif(arr[i] < arr[i*2]):
                        swap(arr, i, i*2)
                    elif(arr[i] < arr[i*2 + 1]):
                        swap(arr, i, i*2 + 1)
                    else:
                        flag_swap = False
                if(not flag_swap):
                    break
            arr_sorted.append(arr[0])
            arr[0] = arr[-1]
            del arr[-1]
            if(len(arr) <= 2):
                if(arr[0] < arr[1]):
                    swap(arr, 0, 1)
                arr_sorted.extend(arr)
                break
    arr_sorted.reverse()
    return arr_sorted

a = heap_sort(a)
a.reverse()

al = 0
bo = 0

flag = True
for i in a:
    if(flag):
        al += i
        flag = False
    else:
        bo += i
        flag = True
print(al - bo)

# Example run
# Input:
187
-33958
# Output:
-33958
N=int(input())

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

if N%2 == 1:
    cards.append(0)

cards=sorted(cards)
ret=0
i=len(cards)-1

while i>=0:
    ret+=cards[i]-cards[i-1]
    i-=2

print(ret)

# Example run
# Input:
411
-981245579
# Output:
981245579
N = int(input())
A = sorted(list(map(int, input().split())),reverse=True)

Alice = sum(A[0::2])
Bob = sum(A) -Alice
print(Alice-Bob)

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

A = sorted(a)

ans = 0
for i in range(N):
  if i % 2 == 0:
    ans += A[-1]
  else:
    ans -= A[-1]
  A.pop()
print(ans)

# Example run
# Input:
-726599
11
# 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]
        print(y[i-1])
    else:
        b += y[i-1]
print(a-b)

# Example run
# Input:
-1406309
-967
# Output:
0
n = int(input())
a = sorted([int(x) for x in input().split()], reverse = True)
alice = 0
bob = 0
for x in range(n):
    if x % 2 == 0:
        alice += a[x]
    else:
        bob += a[x]

print(alice - bob)


# Example run
# Input:
-1622400
-55564347
# Output:
0
N = int(input())
l = list(map(int,input().split()))
sorted_l = sorted(l,reverse=True)
alice = sum(sorted_l[0::2])
bob = sum(sorted_l[1::2])
print(alice - bob)

# Example run
# Input:
0
-84521052
# Output:
-84521052
N = int(input())
a = [110]
a = list(map(int, input().split()))
a.sort(reverse=True)
 
Alis = 0
Bob = 0
for j in range(N):
  if j % 2 == 0:
    Alis += a[j]
  else:
    Bob += a[j]
    
print(Alis-Bob)

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


# Example run
# Input:
860
0
# Output:
0
N = int(input())
a = input().split()
a = list(map(int, a))
Alice = 0
Bob = 0
for i in range(N):
    if i % 2 == 0:
        Alice += a.pop(a.index(max(a)))
    else:
        Bob += a.pop(a.index(max(a)))
print(Alice - Bob)

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

A = 0
B = 0

n = round(N/2+0.1)

while True:
  try:
    A = A + max(a)
    a.pop(a.index(max(a)))
    B = B + max(a)
    a.pop(a.index(max(a)))
  except:
    break

print(A-B)

# Example run
# Input:
19
-4868286
# Output:
-4868286
N = int(input())
itemList = input().split(' ')
itemList.sort()
itemList.reverse()

A = 0
B = 0

for i in range(0, len(itemList)):
    if i % 2 == 0:
        A += int(itemList[i])
    else:
        B += int(itemList[i])

print(A-B)

# Example run
# Input:
499561877
9
# Output:
9
N = int(input())
A = [int(i) for i in input().split()]
sorted_A = sorted(A, reverse=True)

a_sum = 0
b_sum = 0

for i in range(N):
    if i % 2 == 0:
        a_sum += sorted_A[i]
    else:
        b_sum += sorted_A[i]

print(a_sum - b_sum)

# Example run
# Input:
-18231
54
# Output:
0
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
ab = [0, 0]
is_alice = True
while len(A) != 0:
    now = A.pop()
    if is_alice:
        ab[0] += now
        is_alice = False
    else:
        ab[1] += now
        is_alice = True
print(ab[0] - ab[1])


# Example run
# Input:
60
55
# Output:
55
N=int(input())
a=sorted(list(map(int,input().split())))
ra=a[:]
ra.reverse()
sumofAlice=sum(ra[::2])
sumofBob=sum(ra[1::2])
print(sumofAlice-sumofBob)

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

# Example run
# Input:
-299483
83
# Output:
83
N=int(input())
cards = list(map(int, input().split()))
cards.reverse
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:
11919
8647
# Output:
8647
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:
-640183291
155287
# Output:
0
n = int(input())
li = list(map(int,input().split()))
li.sort(reverse=True)
alice = li[0::2]
bob = li[1::2]
print(sum(alice)-sum(bob))

# Example run
# Input:
3132478
-7930
# Output:
-7930
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:
-6212597
36241
# Output:
36241
n = int(input())
a = [int(x) for x in input().split()]

a.sort(reverse=True)
res = 0
s = 1
for d in a:
  res += s * d
  s *= -1

print(res)


# Example run
# Input:
98
5881
# Output:
5881
n=int(input())
a_list=list(input().split())
a_list = [int(n) for n in a_list]
a_list.sort(reverse=True)
a = 0
b = 0
for i in range(n):
    if i % 2 == 0:
        a += int(a_list[i])
    elif i % 2 == 1:
        b += int(a_list[i])
print(a-b)

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

alice, bob = 0, 0

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

print(alice - bob)

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

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

# Example run
# Input:
20
185419405
# Output:
185419405
n = int(input())
aa = list(sorted(map(int, input().split())))
print(abs(sum(aa[::2]) - sum(aa[1::2])))

# Example run
# Input:
150
-18771736
# Output:
18771736
N = int(input())
a = list(reversed(sorted([int(x) for x in input().split()])))

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


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


# Example run
# Input:
988493674
-30547349
# Output:
-30547349
n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)

alice = 0
bob = 0

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

print(alice - bob)


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

# Example run
# Input:
CA{q
41555
# Output:
41555
n = int(input())
list = input().split()
list = [int(i) for i in list]

list = sorted(list)[::-1]
alice = list[::2]
bob = list[1::2]
print(sum(alice)-sum(bob))


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

a = sorted(a, reverse=True)
ans = a[0]
m = 1
for i in range(1,n):
    m *= -1
    ans += m * a[i]

print(ans)

# Example run
# Input:
-58743
-207
# Output:
-207
n=int(input())
a=map(int,input().split())
lis=list(a)
lis.sort()
ali=0
bob=0
for i in range(n):
  if i%2==0:
    ali+=lis.pop()
  else:
    bob+=lis.pop()
print(ali-bob)

# Example run
# Input:
-8439645
709214891
# Output:
0