Felix6326727/beyond-accuracy-code-comprehension huggingface dataset:
alice = 0
bob = 0
n = int(input())
a = list(map(int,input().split()))
sorted_a = sorted(a, reverse=True) 

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

print(alice - bob)

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

# Example run
# Input:
2147483647
1270
# Output:
1270
N = int(input().strip(" "))
a = list(map(int, input().strip().split(" ")))

a.sort()    #ソート

alice =[]
bob = []

i = 0

while(len(a) > 0):
    if (i % 2 == 0):        
        alice.append(a.pop(0))
        i += 1
    else:
        bob.append(a.pop(0))
        i += 1

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

# Example run
# Input:
-175982883
182
# Output:
182
#!/usr/bin/env python3

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

a.sort(reverse=True)

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

print(x-y)


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

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

# Example run
# Input:
31946
-3122
# Output:
-3122
#N枚のカードを大きい順に並べたリストを作成し、0,2,4,...番目をAliceが、1,3,5,...番目をBobが取ると考え、これらの総和の差を出力する
N = int(input())
a = list(map(int, input().split()))
b = sorted(a)[::-1]
Alice = 0
Bob = 0
for i in range(len(b)):
	if i % 2 == 0:
		Alice = Alice + b[i]
	else:
		Bob = Bob + b[i]
print(Alice - Bob)


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

# Example run
# Input:
-439
20405993
# Output:
20405993
N = int(input())
a = list(map(int, input().split()))
a = sorted(a)
sum1 = 0
sum2 = 0
for i in reversed(range(0,len(a))):
	if(i%2==0):
		sum1+=a[i]
	if(i%2==1):
		sum2+=a[i]
print(abs(sum1-sum2))

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


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

res = 0

for i in range(N):
    if i % 2 == 0:
        res += a_list[i]
    if i % 2 == 1:
        res -= a_list[i]

print(res)


# Example run
# Input:
-80
19
# Output:
0
n=int(input())
al=list(map(int,input().split()))
al.sort(reverse=True)
alice=0;bob=0
for i,ai in enumerate(al):
    if i%2==0:
        alice+=ai
    else:
        bob+=ai
print(alice-bob)

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

alice = 0
bob = 0


while(N !=0) :
    
        
        maxa = max(a)
        max_index = a.index(max(a))
        del a[max_index]

        alice = alice + maxa
        N = N -1

        if (N == 0):
            break
    
        
        
        maxa = max(a)
        max_index = a.index(max(a))
        del a[max_index]

        bob = bob + maxa
        N = N -1

print(alice - bob)

# Example run
# Input:
1
-7617381
# Output:
-7617381
n = int(input())
a = list(map(int, input().split()))
a.sort()
ab = [x for x in a[1::2]]
ba = [x for x in a[0::2]]
print(abs(sum(ab)-sum(ba)))

# Example run
# Input:
32
-1
# Output:
1
#python3
def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    a.sort(reverse=True)
    print(sum([a[i] for i in range(n) if i%2 == 0]) - sum([a[i] for i in range(n) if i%2 !=0]))
main()



# Example run
# Input:
-3528
-5900
# Output:
0
a = int(input())
b = list(map(int, input().split()))
ans1 = 0
ans2 = 0
c = sorted(b, reverse=True)
for i in range(a):
    if i % 2 ==1:
        ans1 += c[i]
    else:
        ans2 += c[i]
print((ans1-ans2)*-1)

# Example run
# Input:
-7038374
-6
# Output:
0
# 2020-08-30, Sun

n = int(input())
lis = sorted(list(map(int, input().split())))

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

# Example run
# Input:
66907706
3425848
# Output:
-3425848
n = int(input())
a = [int(x) for x in input().split()]
a.sort(reverse=True)
print(sum(a[::2])-sum(a[1::2]))

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

# Example run
# Input:
19
-4868286
# Output:
-4868286
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:
32
-836
# Output:
-836
# -*- coding: utf-8 -*-
a = int(input())  # Nを入力
b = input()  # a1,a2...anを入力
b = map(int, b.split())  # a1,a2...anをint型でリストに入れる
b = sorted(b)  # 大きい順に並べる
b = b[::-1]  # リストの要素の順番を逆転する
c = b[::2]  # Aliceのとる要素を抽出
c_number = len(c)
d = b[1::2]  # Bobのとる要素を抽出
d_number = len(d)
c_sum = 0
d_sum = 0
for i in range(c_number):  
    c_sum += c[i] # Aliceのとる要素の合計

for g in range(d_number):
    d_sum += d[g]  # Bobのとる要素の合計

print(c_sum - d_sum)  # 差分を出力

# Example run
# Input:
-473
-7
# Output:
-7
N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
A_cards = []
B_cards = []
flag = 'A'
for card in A:
    if flag == 'A':
        flag = 'B'
        A_cards.append(card)
    elif flag == 'B':
        flag = 'A'
        B_cards.append(card)
print(sum(A_cards) - sum(B_cards))

# Example run
# Input:
10559
1792657
# Output:
1792657
n = int(input())
aList = list(map(int, input().split()))
aList.sort(reverse=True)
sums = 0
for i in range(n):
    if i % 2 == 0:
        sums += aList[i]
    else:
        sums -= aList[i]
print(sums)

# Example run
# Input:
-39
2569
# Output:
0
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
alice = 0
bob = 0
flag_alice = True
for num in a:
    if flag_alice:
        alice += num
        flag_alice = False
    else:
        bob += num
        flag_alice = True
print(alice - bob)

# Example run
# Input:
470
499561877
# Output:
499561877
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
b=[a[i] for i in range(n) if i%2==0]
print(2*sum(b)-sum(a))

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

# Example run
# Input:
-5363
1552
# Output:
1552
n=int(input())
lst=sorted(list(map(int,input().split())))
print(abs(sum(lst[1::2])-sum(lst[0::2])))

# Example run
# Input:
-31
-58867430
# Output:
58867430
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"


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

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

    return alice - bob


def main():
    print(solve())


if __name__ == '__main__':
    main()

# Example run
# Input:
-2
1973033
# Output:
1973033
N = int(input())
A = list(map(int,input().split()))
A.sort()
B = A[0::2]
b = sum(B)
C = A[1::2]
c = sum(C)
if b >= c:
  print(b-c)
else:
  print(c-b)

# Example run
# Input:
-39355
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:
2
0
# Output:
0
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

bob = []
alice = []

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:
-104837
-69520
# 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:
-2031692
-1843740
# Output:
-1843740
# https://atcoder.jp/contests/abc088/tasks/abc088_b?lang=ja

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

a.sort(reverse=True)

alice_score = 0
bob_score = 0

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

print(alice_score - bob_score)
# https://atcoder.jp/contests/abc088/tasks/abc088_b?lang=ja

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

a.sort(reverse=True)

alice_score = 0
bob_score = 0

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

print(alice_score - bob_score)


# Example run
# Input:
-7
-7737
-126905272
28016
# Output:
-7737
28016
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
alice = a[0::2]
bob = a[1::2]
print(sum(alice) - sum(bob))

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

a.sort(reverse=True)

a_ = []
b_ = []
for i,j in enumerate(a):
    if i%2 == 0:
        a_.append(j)
    else:
        b_.append(j)
        
print(sum(a_)-sum(b_))


# Example run
# Input:
10366
-5271130
# Output:
-5271130
N=int(input())
aList=sorted(list(map(int,input().split())))[::-1]

Alice=0
Bob=0

for i in range(1,N+1):
  if i%2 == 1:
    Alice+= aList[i-1]
  else :
    Bob+= aList[i-1]

print(Alice-Bob)

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

# Example run
# Input:
-558
15964
# Output:
15964
def main():
    n = int(input()) 
    a = list(map(int,input().split()))
    a.sort()
    o , e = 0 , 0 
    for i in range(n):
        if i % 2 == 0 :
            e += a[i] 
        else:
            o += a[i]
    print(abs(e-o))
main()

# Example run
# Input:
-21
6534
# Output:
0
# 整数の入力
n = input()
n = int(n)

# いくつあるかわからないときのスペース区切りの整数の入力
nums = input().split()
nums = list(map(int,nums))

print(nums)

nums.sort(reverse=True)

print(nums)

i = 0
Alis = 0
Bob = 0

for i in range(0,n):
    if i % 2 == 0:
        Alis = Alis + nums[i]
    else:
        Bob = Bob + nums[i]

print(Alis-Bob)

#print(Alis)
#print(Bob)


# Example run
# Input:
1
-124978655
# Output:
[-124978655]
[-124978655]
-124978655
n = int(input())
lista = list(map(int, input().split()))

point = 0

lista.sort()

for _ in range((n + 1) // 2):
  point += lista.pop()
  if lista == []:
    break
  else:
    point -= lista.pop()
    
print(point)

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

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

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


# Example run
# Input:
-110923
13499019
# Output:
0
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[i]
  else:
    B += a[i]
    
print(A-B)


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

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

a.sort(reverse=True)

score_a = a[::2]
score_b = a[1:][::2]

print(sum(score_a) - sum(score_b))


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

# Example run
# Input:
VX^
-11
# Output:
-11
n = int(input())
l = list(map(int,input().split()))

l.append(0)
_n = int(len(l)/2)

a = 0
b = 0

l.sort(reverse=True)

for i in range(_n):
  a += l[i*2]
  b += l[i*2 + 1]

print(a-b)

# Example run
# Input:
243
0
# Output:
0
n = int(input())
a = [num for num in map(int, input().split())]

a.sort(reverse=True)

#print(n, a)

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

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

# Example run
# Input:
K_u7\fXD
-2608672
# Output:
-2608672
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse = True)
print(sum(A[::2]) - sum(A[1::2]))

# Example run
# Input:
-12503953
-345658
# Output:
-345658
N=int(input())
a = list(map(int, input().split()))
a2=sorted(a,reverse=True)
b1=a2[1::2]
b2=a2[0::2]
alice=sum(b1)
bob=sum(b2)
print(alice-bob)

# Example run
# Input:
-2
669
# Output:
-669
n = int(input())
l = list((map(int, input().split())))

l.sort()
l.reverse()
alice = sum(l[::2])
bob = sum(l[1::2])
print(alice - bob)

# Example run
# Input:
-221907
-154
# Output:
-154
N = int(input())
card = list(map(int, input().split()))
card.sort(reverse = True)

A = 0
B = 0

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

print(A - B)

# Example run
# Input:
-1138
-22588477
# Output:
0
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:
0
-6956
# Output:
0
N = int(input())
a = list(map(int,input().split()))
a.sort()
alice = 0
bob = 0
for i in range(N): #合計N回引く
    if i%2 == 0:#偶数回＝Alice
        alice += max(a)
        del a[-1]
    else:
        bob += max(a)
        del a[-1]
print(alice - bob)

# Example run
# Input:
-4664
26550845
# Output:
0
N=int(input())
L=list(map(int,input().split()))
L=sorted(L,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:
-90312
-12211339
# Output:
0
n = int(input())
a = sorted([int(i) for i in 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:
-3550
-11385106
# Output:
0
n = int(input())
a = list(map(int, input().split()))
ans = 0
a.sort(reverse = True)

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

print(ans)

# Example run
# Input:
-31
224
# Output:
224
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
ans = 0
for k in range(len(a)):
    ans += a[k]*((-1)**k)

print(ans)

# Example run
# Input:
141725276
-109089799
# Output:
-109089799
n = int(input())
line = input().split(" ")
a = list(map(int, line))
a.sort(reverse=True)
ascore = 0
bscore = 0
for i in range(0, len(a)):
    if i % 2 == 0:
        ascore += a[i]
    else:
        bscore += a[i]
print(ascore - bscore)


# Example run
# Input:
810667242
571186857
# Output:
571186857
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)

Score = 0
for i, j in enumerate(a):
	if i & 1 == 0:
		Score += j
	else:
		Score -= j

print(Score)

# Example run
# Input:
1
3770
# Output:
3770
n = int(input())
l = list(map(int, input().split(' ')))

l.sort()
l.reverse()

result = 0

for e in enumerate(l):
    result += e[1] if e[0] % 2 else -e[1]

print(result)

# Example run
# Input:
-60254091
-960
# Output:
960
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:
-62350830
260615611
# Output:
0
n = int(input())
s = [int(x) for x in input().split(' ')]

s = sorted(s, reverse=True)

Alice = 0
Bob = 0

for i, x in enumerate(s):
  if i%2==0:
    Alice+=x
  else:
    Bob+=x
    
print(str(Alice-Bob))

# Example run
# Input:
331292818
1
# Output:
1
N = int(input())
ai = [int(n) for n in input().split(' ')]

ai.sort(reverse=True)

A = sum(ai[::2])
B = sum(ai[1::2])

print(A-B)


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

Alice = []
Bob = []

while N != 0:
        Alice.append(max(data))
        data.remove(max(data))
        if len(data) == 0:
                break
        else:
                Bob.append(max(data))
                data.remove(max(data))
        N -= 1

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

# Example run
# Input:
-39
2569
# Output:
2569
N = int(input())
X = list(map(int,input().split()))

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

# Example run
# Input:
134
-5930
# Output:
-5930
# coding: utf-8
"""this is python work script"""

def find_score(card_list):
    """return score list about a and b"""
    sum_a, sum_b = 0, 0
    card_list.sort()
    
    for i in range(len(card_list)):
        if i % 2 == 0:
            sum_a += card_list.pop()
        else:
            sum_b += card_list.pop()
            
    return sum_a, sum_b

def solve(card_list):
    """solve problem"""
    a_score, b_score = find_score(card_list)
    diff_score = a_score - b_score
    
    return diff_score

def main():
    """main method"""
    _ = input()
    list_cards = list(map(int, input().split(' ')))
    answer = solve(list_cards)
    print(answer)

if __name__ == '__main__':
    main()


# Example run
# Input:
8r+|E
51856
# Output:
51856
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)

alice = 0
bob = 0

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

print(alice - bob)
        


# Example run
# Input:
1
-124978655
# Output:
-124978655
n = input()
ma = map(int, input().split())
ls = []
for m in ma:
  ls.append(m)
ls.sort()
jdg = 0
Alice = 0
Bob = 0

for l in reversed(ls):
  if jdg == 0:
    Alice = Alice + l
  else:
    Bob = Bob + l
  jdg = 1 - jdg

print(Alice - Bob)

# Example run
# Input:
4EPy8r+|E
51856
# Output:
51856
N = int(input())

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

a.reverse()

A = []
B = []

for x in range(0,N,2):
    A.append(a[x])
    
        
for y in range(1,N,2):
    B.append(a[y])
    
print(sum(A)-sum(B))
    

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

# Example run
# Input:
-10841372
-2552
# Output:
-2552
n = input()
a = list(map(int, input().split()))
a.sort()
print(abs(sum(a[::2]) - sum(a[1::2])))

# Example run
# Input:
,@oF:Y#j7
-46095437
# Output:
46095437
n = int(input())
num_lists = list(map(int, input().split()))

num_lists.sort()
num_lists.reverse()
alice_num_lists = []
bob_num_lists = []

for i in range(n):
  if i%2 == 0:
    alice_num_lists.append(num_lists[i])
  else:
    bob_num_lists.append(num_lists[i])

alice_score = 0
bob_score = 0
for i in alice_num_lists:
  alice_score += i
for i in bob_num_lists:
  bob_score += i

print(alice_score - bob_score)

# Example run
# Input:
-8
-39
# Output:
0
n = int(input())
c = list(map(int,input().split()))
a = 0
b = 0
c.sort(reverse=True)
for i,j in enumerate(c):
  if i%2 == 0:
    a+=j
  else:
    b+=j
print(a-b)

# Example run
# Input:
6
-224852
# Output:
-224852
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:
-30714356
-1
# Output:
0
N = int(input())
A = sorted(list(map(int, input().split())))
print(sum(A[0::2])-sum(A[1::2]))

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

print(ans)


# Example run
# Input:
-473
-7
# Output:
0
N = int(input())
s = list(map(int,input().split()))
s.sort()
alice = 0
bob = 0
for n in range((N+1)//2):
    alice += s[-1]
    del s[-1]
    try:
        bob += s[-1]
        del s[-1]
    except IndexError:
        break
print(alice-bob)

# Example run
# Input:
34675473
-579377
# Output:
-579377
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
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:
-7
-7737
# Output:
0
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:
28016
-48
# Output:
-48
N = int(input())
a = list(map(int,input().split()))

a.sort(reverse=True)

ans = 0

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

  
print(ans)


# Example run
# Input:
-525059
89101055
# Output:
0
n = int(input())
lis = list(map(int, input().split()))

lis = sorted(lis, reverse = True)

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

print(a-b)

# Example run
# Input:
-1817683
-11385106
# Output:
0
n = int(input())
l = [int(i) for i in input().split()]
l = sorted(l, reverse=True)

alice = sum(l[::2])
bob = sum(l[1::2])

print(alice-bob)


# Example run
# Input:
33729406
142
# Output:
142
#ABC088-B
n = int(input())
a = list(map(int,input().split()))
alice = []
bob = []
a.sort(reverse=True)
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:
-1138
-22588477
# Output:
0
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:
-1350
-161
# Output:
0
N = int(input())
Li = list(map(int,input().split()))
Li = sorted(Li)
a = 0
b = 0
while True:
    a += Li.pop()
    if not Li:
        break
        
    b += Li.pop()
    if not Li:
        break

print(a - b)

# Example run
# Input:
51856
15
# Output:
15
if __name__ == "__main__":
    N = int(input())
    A = list(map(int, (input().split(' '))))
    alice_sum = 0
    bob_sum = 0
    A.sort()
    A.reverse()
    for i in range(N):
        if i % 2 == 0:
            alice_sum += A[i]
        else:
            bob_sum += A[i]
    print(alice_sum - bob_sum)

# Example run
# Input:
-168854
-5
# 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:
465
-2090237817
# Output:
-2090237817
N=int(input())
a=list(map(int,input().split()))
a=sorted(a[::-1])
A=a[0::2]
B=a[1::2]
print(abs(sum(A)-sum(B)))

# Example run
# Input:
463316186
-3
# Output:
3
n = int(input())
cards = [int(i) for i in input().split()]
alice = 0
bob = 0

for j in range(n):
    if j%2 == 0:
        alice += cards.pop(cards.index(max(cards)))
    else:
        bob += cards.pop(cards.index(max(cards)))

print(alice - bob)


# Example run
# Input:
-3249
901872
# Output:
0
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse = True)
s = []
d = []
for i in range(0,n,2):
    s.append(a[i])
for j in range(1,n,2):
    d.append(a[j])
print(sum(s)-sum(d))

# Example run
# Input:
-960
1892351448
# Output:
0
N = int(input())
a_i = list(map(int, input().split()))

a_i.sort(reverse = True)

L_a = []
L_b = []

for i in range(0, N, 2):
    L_a.append(a_i[i])

for i in range(1, N, 2):
    L_b.append(a_i[i])

print(sum(L_a) - sum(L_b))


# Example run
# Input:
0
-11989124
# Output:
0
N = int(input())
card = list(map(int,input().split()))
sorted_card = sorted(card)
Alice = 0
Bob = 0

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

print(Alice - Bob)

# Example run
# Input:
-46896159
2561
# Output:
0