Felix6326727/beyond-accuracy-code-comprehension huggingface dataset:
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    A.reverse()
    ans = 0
    for i in range(0, N-1, 2):
        ans += A[i] - A[i+1]
    if N % 2 == 1:
        ans += A[-1]
    return ans

print(solve())


# Example run
# Input:
-25
392836532
# Output:
392836532
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:
4176895
-16198
# Output:
-16198
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
ans = 0
for i in range(n):
  ans += a[i] * ((-1) ** i)
print(ans)

# Example run
# Input:
-3753932
42339391
# Output:
0
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)]

    re = 0
    B = sorted(A, reverse=True)

    for i in range(len(B)):
        if i % 2 == 0:
            re += B[i]
        else:
            re -= B[i]
    print(re)
resolve()

# Example run
# Input:
-10855
-91379208
# Output:
-91379208
N = int(input())

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

#リストを大きい順に並び替える
A.sort(reverse=True)
#print(A)

#Aliceは要素0から偶数分加算
Alice = sum(A[0::2])
#Bobは要素1から奇数分加算
Bob = sum(A[1::2])

#print(Alice,Bob)

#AliceからBobを引く
print(Alice-Bob)

# Example run
# Input:
669
23
# Output:
23
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:
-1643990
363865392
# Output:
363865392
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])

ans = sum(alice) - sum(bob)

print(ans)

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

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

A = 0
B = 0
while(True):
 mx = max(a)
 if mx == -1: break
 mx_idx = a.index(mx)
 a[mx_idx] = -1
 A += mx
 
 mx = max(a)
 if mx == -1: break
 mx_idx = a.index(mx)
 a[mx_idx] = -1
 B += mx

print(A-B)

# Example run
# Input:
49391
22434
# Output:
22434
n=int(input())

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

for i in range(n):
    for j in range(n):
        if a[i] < a[j]:
            work = a[i]
            a[i] = a[j]
            a[j] = work

s1 = 0
s2 = 0

for i in range(0,n,2):
    s1 += a[i]

for i in range(1,n,2):
    s2 += a[i]

output = s2-s1

if output < 0:
    output *= -1

print(output)

# Example run
# Input:
-2239572
-31
# Output:
0
N =int(input())
l = [int(i) for i in input().split()]
l.sort(reverse=True)
alice = l[0::2]
bob = l[1::2]
print(sum(alice) - sum(bob))

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

sa=0
sb=0

a=sorted(a,reverse=True)

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

print(sa-sb)
    


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

# Example run
# Input:
-40
-18579092
# Output:
-18579092
N=int(input())
ls=input().split()
l=[ int(v) for v in ls ]

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:
-2540
-1836
# Output:
0
n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
Alice = 0
Bob = 0
tf = 0
for i in l:
    if tf == 0:
        Alice += i
        tf = 1
    else:
        Bob += i
        tf = 0
ans = Alice - Bob
print(ans)

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

# Example run
# Input:
242208
94838
# Output:
94838
input()
A = list(map(int, input().split()))
x = 0
y = 0
t = 0
while A:
	m = max(A)
	if t == 0:
		x += m
		t = 1
	else:
		y += m
		t = 0
	A.remove(m)
print(x-y)

# Example run
# Input:
H3"Fn!
34675473
# Output:
34675473
N=int(input())

a=list(map(int,input().split()))
a=sorted(a,reverse=True)
Alice=[]
Bob=[]

for index,num in enumerate(a):
    if index%2 == 0:
        Alice.append(num)
    else:
        Bob.append(num)
        

ans=sum(Alice)-sum(Bob)

print(ans)

# Example run
# Input:
-18579092
21643
# Output:
21643
n = int(input())
X = list(map(int, input().split(' ')))

X.sort(reverse = True)

x = sum(X)
a = sum(X[0::2])

b = x - a

print(a-b)

# Example run
# Input:
-32460
-375
# Output:
-375
n = int(input())
x = list(map(int, input().split()))
a=0
b=0
def max():
    m = 0
    j = 0
    for i in range(len(x)):
        if x[i]>m:
            m=x[i]
            j=i
    x.pop(j)
    return m
if n%2 == 0:
    i=0
    while i<n:
        a += max()
        b += max()
        i += 2
else:
    i=0
    while i<n-1:
        a += max()
        b += max()
        i += 2
    a+=max()
print(a-b)

# Example run
# Input:
-5024207
-2147483648
# Output:
0
n = int(input())
a = list(map(int, input().split()))
b = sorted(a, reverse=True)

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


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

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

print(total)

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

# Example run
# Input:
-219310
-696
# Output:
-696
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:
-5
332
# Output:
0
N = int(input())
 
card = list(map(int, input().split()))
card.sort(reverse=True)
 
Alice = 0
Bob = 0
for i in range(N):
  if i % 2 == 0:
    Alice += card[i]
  else:
    Bob += card[i]
    
print(Alice - Bob)


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

# Example run
# Input:
28016
-48
# Output:
-48
n = int(input())
A = list(map(int,input().split()))
A = sorted(A,reverse=True)
A_card = []
B_card = []
for i in range(n):
        if i%2 == 0:
                A_card.append(A[i])
        else:
                B_card.append(A[i])
print(sum(A_card) - sum(B_card))

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

# Example run
# Input:
-40780112
-13
# Output:
-13
s = input()
n = int(s)

cards = []

v = input().split()
for i in range(n):
    cards.append(v[i])

v = sorted(v,reverse=True)

alice_array = []
bob_array = []

for i in range(len(v)):
    if i % 2 == 0:
        alice_array.append(v[i])
    else:
        bob_array.append(v[i])

sum_alice = 0
sum_bob = 0
for i in range(len(alice_array)):
    sum_alice += int(alice_array[i])

for i in range(len(bob_array)):
    sum_bob += int(bob_array[i])

answer = sum_alice - sum_bob
print(answer)


# Example run
# Input:
-224852
-318594
# Output:
-318594
N = int(input())
a_line_map = map(int, input().split(' '))

#sorted_a_map <- a_line_map 降順ソート
sorted_a_map = sorted(a_line_map, reverse=True)
#diff_map <- sorted_a_map 奇数 -1倍
diff_map = (num if i%2==0 else -num for i,num in enumerate(sorted_a_map))
print(sum(diff_map))

# Example run
# Input:
515448
-514355545
# Output:
-514355545
n = int(input())
a = [int(i) for i in input().split()]
alice = 0
bob = 0

while a != []:
  alice += max(a)
  a.remove(max(a))
  try:
  	bob += max(a)
  except:
    break
  try:
    a.remove(max(a))
  except:
    break
    
print(alice-bob)

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

alice=sum(s[::2])
bob=sum(s)-alice
print(alice-bob)

# Example run
# Input:
54
-86
# Output:
-86
n = int(input())

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

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

Bob = sum(a)-Alice

print(Alice-Bob)


# Example run
# Input:
-5900
-802253
# Output:
802253
N = int(input())
a = list(map(int,input().split()))
a.sort()
a.reverse()
Alice = []
Bob = []
if N % 2 == 0:
    for i in range(N//2):
        Alice.append(a[i*2])
        Bob.append(a[i*2+1])
    print(sum(Alice) - sum(Bob))
elif N % 2 == 1 and N != 1:
    for i in range((N-1)//2):
        Alice.append(a[i*2])
        Bob.append(a[i*2+1])
        Alice.append(a[-1])
    print(sum(Alice) - sum(Bob))
elif N == 1:
    print(a[0])

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

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

# Example run
# Input:
-224960337
446
# Output:
446
n = int(input())
a = list(map(int, input().split()))
Alice = 0
Bob = 0
for i in range(n):
    try:
        a = sorted(a, reverse = True)
        Alice += a[0]
        del(a[0])
        Bob += a[0]
        del(a[0])
    except:
        break
print(Alice - Bob)



# Example run
# Input:
-17367
-40831043
# Output:
0
N=int(input())
lst=list(map(int,input().split()))
lst.sort(reverse=True)

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

print(int(A)-int(B))

# Example run
# Input:
-56446
120644
# Output:
0
# coding: utf-8
N = int(input())

list = input().split(" ")
num_list = []

for num in list:
    num_list.append(int(num))

num_list.sort(reverse=True)

alice = 0
bob = 0

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

print(alice - bob)

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

a = sorted(a, reverse = True)
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
a = int(input())
b = list(map(int,input().split()))
b.sort()
c = sum(b[::2])
d = sum(b[1::2])
print(d-c)

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

# Example run
# Input:
176397305
-2046600
# Output:
-2046600
cnt = int(input())
numlist = list(map(int,input().split()))
list.sort(numlist, reverse=True)
A = 0
B = 0

for x in range(cnt):
    if x % 2 == 0:
        A += numlist[x]
    else:
        B += numlist[x]

print(A-B)

# Example run
# Input:
-740
1
# Output:
0
a=int(input())
b=[int(i) for  i in input().split()]
c=sorted(b,reverse=True)
x=0
y=0
for j in range(len(c)):
  if j%2==0:
    x+=c[j]
  else:
    y+=c[j]
print(x-y)

# Example run
# Input:
986892
57712056
# Output:
57712056
N = int(input()) #入力値
A = sorted(map(int, input().split()), reverse = True)
Bob=0
Alice=0
print(A)
for i in range(0,N):
      if i % 2 == 0: # Bobが偶数なら実行
         Alice=Alice+int(A[i])
      else:
         Bob=Bob+int(A[i])
print(Alice-Bob)


# Example run
# Input:
0
-82547695
# Output:
[-82547695]
0
n=int(input())
a=sorted(map(int,input().split()))
alice=0
bob=0

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

print(alice-bob)

# Example run
# Input:
-30547349
2147483647
# Output:
0
N = int(input())
A = [int(x) for x in input().split()]
A.sort(reverse=True)
Alice = A[::2]
Bob = A[1::2]
ans = sum(Alice) - sum(Bob)
print(ans)

# Example run
# Input:
-3528
-5900
# Output:
-5900
def main(n,a):
    #カードを大きい順に並び替える
    a.sort(reverse = True)
    #奇数番目がアリス、偶数番目がボブ
    alis = a[0::2]
    bob = a[1::2]
    return sum(alis) - sum(bob)

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

# Example run
# Input:
-5900
-802253
# Output:
-802253
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
point = 0
calc = True
for i in a:
    if calc:
        calc = False
        point += i
    else:
        calc = True
        point -= i

print(point)

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

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

a.sort(reverse=True)

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

print(alice-bob)


# Example run
# Input:
695
2147483647
# Output:
2147483647
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:
-202
-5056872
# Output:
0
n = int(input())
cardList = list(map(int,input().split()))
a = 0
b = 0
cardList.sort(reverse=True)
for i in range(n):
    if(i % 2 == 0):
        a += cardList[i]
    else:
        b += cardList[i]
print(a-b)

# Example run
# Input:
-111119678
-646
# Output:
0
if __name__ == '__main__':
    n = int(input())
    ai = list(map(int, input().split()))

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

# Example run
# Input:
0
-6956
# Output:
-6956
n = int(input())
a = [int(i) for i in input().split()]
a.sort
print(sum(a[::2]) - sum(a[1::2]))

# Example run
# Input:
-24
-35784
# Output:
-35784
n=int(input())
a=list(map(int,input().split()))
ans=0
a.sort(reverse=True)
if len(a)%2==1:
	a.append(0)
for i in range(0,n,2):
	ans+=a[i]-a[i+1]
print(ans)

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

# Example run
# Input:
q=rx[akum
0
# 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:
-2147483648
450137
# Output:
0
N = int(input())
lst = [int(x) for x in input().split(" ")]

lst.sort(reverse = True)

a = lst[::2]
b = lst[1::2]
print(sum(a)-sum(b))

# Example run
# Input:
-156960
-16
# Output:
-16
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:
-39
2569
# Output:
2569
# coding: utf-8
# Your code here!
N = int(input())
a = list(map(int, (input().rstrip().split())))
a_sort = sorted(a, reverse=True)
A = 0
B = 0
for i in range(len(a_sort)):
    if i % 2 == 0:
        A += a_sort[i]
    else:
        B += a_sort[i]
print(A - B)


# Example run
# Input:
-41270
-2
# Output:
-2
#! env python
# -*- coding: utf-8 -*-

import os
import sys


# ac_py.main
# Date: 2020/06/08
# Filename: main 
# Author: acto_mini

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


if __name__ == '__main__':
    main()


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

# Example run
# Input:
-82547695
-84564737
# Output:
0
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]
print(ans)

# Example run
# Input:
-87
141725276
# Output:
0
N=int(input())
A=input().split(" ")
A = list(map(int, A))
A.sort(reverse=True)
Alice = sum(A[0::2])
Bob = sum(A[1::2])
print(Alice-Bob)

# Example run
# Input:
-13840614
2147483647
# Output:
2147483647
n = input()
nums = sorted(list(map(int, input().split())), reverse=True)
result = 0
for i, v in enumerate(nums):
    result += (1 if i % 2 == 0 else -1) * v
print(result)


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

new_a = sorted(a)

A = []
B = []

while len(new_a) != 0:
    if len(new_a) != 0:
        A.append(new_a.pop())
    else:
        break

    if len(new_a) != 0:
        B.append(new_a.pop())
    else:
        break
        

print(sum(A) - sum(B))


# Example run
# Input:
-28418
-29
# Output:
-29
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:
1
2
# Output:
2
N = int(input())
a = [int(i) for i in input().split()]

ans = 0
a.sort()
a.reverse()

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

print(ans)

# Example run
# Input:
-28
-512
# Output:
0
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
N = int(input())
a = list(map(int, input().split()))

if len(a)%2 != 0 :
  a.append(0)
a.sort(reverse=True)

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


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

# Example run
# Input:
-227348
-29
# Output:
0
import math

input()
data = sorted(map(int, input().split(' ')), reverse=True)


s = 0
for i, n in enumerate(data):
    s = s + int(math.pow((-1),(i%2)))*n
print(s)

# Example run
# Input:
CFhk~
65390879
# Output:
65390879
N = int(input())
a = map(int, input().split())

a = sorted(a, reverse=True)

Alice = 0
Bob = 0

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


print(Alice-Bob)



# Example run
# Input:
-330190783
-84564737
# Output:
-84564737
# -*- coding: utf-8 -*-
# B - Card Game for Two
# 標準入力の取得
N = int(input())
A_list = list(map(int, input().split()))

# リストを照準にソートしておく
sorted_A_list = sorted(A_list)

# AliceとBobの差の算出
Alice = 0
Bob = 0

if N % 2 == 0:
    # カード数が偶数の場合、a_2, a_4,・・・, a_NをAliceは取得する
    Alice = sum([sorted_A_list[i] for i in range(N) if i % 2 != 0])
    Bob = sum([sorted_A_list[i] for i in range(N) if i % 2 == 0])
else:
    # カード数が奇数の場合、a_1, a_3,・・・, a_NをAliceは取得する
    Alice = sum([sorted_A_list[i] for i in range(N) if i % 2 == 0])
    Bob = sum([sorted_A_list[i] for i in range(N) if i % 2 != 0])

print(Alice - Bob)

# Example run
# Input:
0
-11989124
# 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:
54
-86
# Output:
-86
n = int(input())
a_list = list(map(int,input().split()))
a_list.sort(reverse=1)
bob = sum(a_list[1::2])
print(sum(a_list)-bob*2)

# Example run
# Input:
-3281
1
# Output:
1
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= list(map(int,input().split()))

a[:n].sort(reverse=True)

A=B=I=0
for i in a:
    if I %2:B+=i
    else:A+=i
    I+=1

print(A-B)
# other
# print(sum(a[::2]) - sum(a[1::2]))


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

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

alice = 0
bob = 0

for i in range(n):

    max_num = max(s)

    if i % 2 == 0:
        alice += max_num
    else:
        bob += max_num

    s.remove(max_num)

print(abs(alice - bob))


# Example run
# Input:
-525602
42329671
# Output:
0
n = input()
a = list(map(int, input().split()))
a= sorted(a, reverse=True)
ans =0
for i in range(len(a)):
    if i%2 == 0:
        ans += a[i]
    elif i%2 ==1:
        ans -= a[i]
print(ans)

# Example run
# Input:
1+^6:
-76824657
# Output:
-76824657
n = int(input())
nums = sorted([int(tok) for tok in input().split()], reverse = True)

alice = sum([nums[i] for i in range(0, n, 2)])
bob = sum([nums[i] for i in range(1, n, 2)])

print(alice - bob)


# Example run
# Input:
-224852
-318594
# Output:
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
input()
l = list(map(int, input().split()))
l.sort(reverse=True)
alice = sum(l[::2])
bob   = sum(l[1::2])
print(alice-bob)


# Example run
# Input:
?HeBTkW0}
-182
# Output:
-182
n = int(input())
a = [int(x) for x in input().split()]

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

print(abs(alice - bob))

# Example run
# Input:
-3
-23909
# 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:
-3
-1
# Output:
0
n = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
alc = 0
bb = 0
for i in range(n):
    if i % 2 == 0:
        alc += A[i]
    else:
        bb += A[i]
print(alc - bb)

# Example run
# Input:
-15015728
42339391
# Output:
0
N = int(input())
a = list(map(int,input().split()))
a.sort(reverse = True)

bob = 0
alice = 0

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

print(alice - bob)

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


# Example run
# Input:
-162200336
-259420352
# Output:
0
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:
-5992
-1
# Output:
-1
n=int(input())
a = list(map(int,input().split()))
a.sort(reverse = True)
A=0
B=0
for i in range(n//2+n%2):
    A+=a[i*2]
for i in range(n//2):
    B+=a[i*2+1]
print(A-B)

# Example run
# Input:
-23
38379
# Output:
0
#coding:utf-8

N = int(input())
a = sorted([int(x) for x in input().split()], reverse=True)

Alice = sum(a[::2])	#最初から最後までを2間隔で取る。
Bob = sum(a[1::2])	#一項から最後までを2間隔で取る。

print(Alice-Bob)

# Example run
# Input:
-86077887
14
# Output:
14
N = int(input())
aList = list(map(int, input().split()))
aList.sort(reverse = True)
point = [0, 0]
for i in range(N):
    point[i%2] = aList[i]
print(point[0] - point[1])

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


# Example run
# Input:
134
-5930
# Output:
-5930
N=int(input())
a=list(map(int,input().split()))
a=sorted(a)
a=list(reversed(a))
ans=0
ans+=sum(a[0:N+1:2])-sum(a[1:N+1:2])
print(ans)

# Example run
# Input:
-56661351
981571
# Output:
0
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
AliceScore = 0
BobScore = 0
for i in range(N):
    if(i%2==0):
        AliceScore += A[i]
    else:
        BobScore += A[i]
score = AliceScore - BobScore
print(score)


# Example run
# Input:
-3318496
-558
# Output:
0
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

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

N=one_int()
A=many_int()

A=sorted(A,reverse=True)

Alice=A[::2]
Bob=A[1:][::2]

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

# Example run
# Input:
3
-563
# Output:
-563
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:
-1
-3439167
# Output:
0