Felix6326727/beyond-accuracy-code-comprehension huggingface dataset:
N = int(input())
A = list(map(int,input().split()))
Alice = []
Bob = []
for i in range(1,N+1):
    if i % 2 != 0:
        Alice.append(A[i-1])
    else:
        Bob.append(A[i-1])
print(sum(Alice)-sum(Bob))

# Example run
# Input:
-607
681963
# Output:
0
n = int(input())
li = list(map(int,input().split()))

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

# Example run
# Input:
-39
2569
# Output:
0
N = int(input())
A = list(map(int,input().split(' ')))
ans = 0
for i in range(N):
    ans = ans + max(A) * (-1) ** i
    A.remove(max(A))
print(ans)

# Example run
# Input:
-8056
-449705
# Output:
0
N = int(input())
list = map(int,input().split(" "))
cards = sorted(list,reverse=True)

if len(cards) % 2 == 0:
    alice = 0
    for i in range(int(N/2)):
        alice = alice + cards[2 * i]
    bob = 0
    for j in range(int(N/2)):
        bob = bob + cards[2 * j + 1]
else:
    alice = 0
    for i in range(int(N/2) + 1):
        alice = alice + cards[2 * i]
    bob = 0
    for j in range(int(N/2)):
        bob = bob + cards[2 * j + 1]
        
print(alice - bob)

# Example run
# Input:
-22914821
-12503953
# Output:
0
N = int(input())
a = [int(n) for n in input().split()]

a = sorted(a, reverse=True)

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

print(alice - bob)

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

# Example run
# Input:
(k9UI.C>
4195951
# Output:
4195951
n = int(input())
a = list(map(int,input().split()))

a.sort()
a.reverse()

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


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

Alice = 0
Bob = 0
cou = 1

for i in range(N):
    if cou % 2 != 0:
        Alice += max(a)
        a.remove(max(a))
    else:
        Bob += max(a)
        a.remove(max(a))
    cou += 1

print(Alice - Bob)

# Example run
# Input:
-728818981
-2811762
# Output:
0
n=int(input())
s=list(map(int,input().split()))
a=sorted(s,reverse=True)
b=[]
c=[]
for i in range(len(a)):
    if i%2==0:
        b.append(a[i])
    else:
        c.append(a[i])
print(sum(b)-sum(c))


# Example run
# Input:
-7
-7737
# Output:
-7737
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse = True)
alice = bob = 0
for i in range(N):
    if i%2 == 0:
        alice += A.pop(0)
    else:
        bob += A.pop(0)
    
print(alice - bob)

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

# Example run
# Input:
?7&49\6
-4505
# Output:
-4505
N=int(input())
alist=list(map(int,input().split()))

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

# Example run
# Input:
-14993
-377
# Output:
-377
def main():
    N = int(input())
    a = [int(i) for i in input().split()]
    a.sort()
    diff = 0
    for i, ai in enumerate(reversed(a)):
        if i % 2 == 0:
            diff += ai
        else:
            diff -= ai
    print(diff)


if __name__ == '__main__':
    main()


# Example run
# Input:
-252699780
988493674
# Output:
988493674
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:
-11989124
-407
# Output:
-407
N=int(input())
a=list(map(int, input().split()))

A=[]
B=[]
while len(a)>0:
    A.append(max(a))
    a.remove(max(a))
    if len(a)>0:
        B.append(max(a))
        a.remove(max(a))
print(sum(A)-sum(B))


# Example run
# Input:
-507526654
-54634663
# Output:
-54634663
n = int(input())
a = [int(i) for i in input().split()]
A  = sorted(a, reverse = True)
ans = sum(A[::2]) - sum(A[1::2])
print(ans)

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

def sort_reverse(n):
    n.sort(reverse=True)
    return n

N_Even = list(range(0, N+1, 2))
N_Odd = list(range(1, N+1, 2))
a1 = sort_reverse(a)
sum1 = 0
sum2 = 0

for i in N_Even:
    sum1 += a1[i]
for j in N_Odd:
    sum2 += a1[i]

print(sum1 - sum2)

# Example run
# Input:
-56834839
1288
# Output:
0
N = int(input())
nums = sorted(map(int,input().split()),reverse=True)
count = 0

for i in range(N):
    if i%2==0:
        count += nums[i]
    else:
        count -= nums[i]
        
print(count)

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

b=sorted(a,reverse=True)

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

print(alice-bob)

# Example run
# Input:
-27566650
49968
# Output:
49968
N = int(input())

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

a.sort()
a.reverse()

Alice = 0
Bob = 0

# print(a)


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

print(Alice -Bob)




# Example run
# Input:
-1643990
363865392
# Output:
363865392
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:
-160045822
155287
# Output:
155287
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ans = sum(A[::2]) - sum(A[1::2])
print(ans)


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


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


# Example run
# Input:
0
31934639
# Output:
31934639
# -*- coding: utf-8 -*-
#input number
num = int(input())
str = input()
#change to list distinguished by space
list = str.split()

#arrange number from high number to low number
list.sort(reverse=True)

sum = 0
for (i, v) in enumerate(list):
  if(i % 2 == 0):
    sum += int(v)
  elif(i % 2 == 1):
    sum -= int(v)
print(sum)

# Example run
# Input:
224
-3753932
# Output:
-3753932
num = int(input())
num_list = [int(i) for i in input().split()]

#大きい順に並び変える
num_list.sort(reverse = True)

senkou = 0
koukou = 0
for i in range(num):
    if i % 2 == 0:
        senkou += num_list[i]
    else:
        koukou += num_list[i]

result = senkou - koukou
print(result)


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

alice = 0
bob = 0

for i in range(1,N+1):
    if i%2 == 1:
        alice += a.pop(a.index(max(a)))
    else:
        bob += a.pop(a.index(max(a)))
print(alice - bob)


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

a = sorted(a, reverse=True)
alice = 0
bob = 0
for i in range(len(a)):
    if i%2==0:
        alice += a[i]
    if i%2==1:
        bob += a[i]
print(alice-bob)

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

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

alice = 0
bob = 0
A.sort(reverse=True)
for ix, a in enumerate(A):
    if ix & 1:
        bob += a
    else:
        alice += a

print(alice - bob)


# Example run
# Input:
-5363
1552
# Output:
1552
# -*- coding: utf-8 -*-

n = int(input())
#tmp = input()
tmp = input().split()
#(lambda a:int(a))(tmp)
hoge = list(map(lambda a: int(a), tmp))
hoge.sort()
hoge.reverse()

sum_al=0
sum_bo=0
for i,j in enumerate(hoge):
	if (i%2 == 0):
		sum_al+=j
	else:
		sum_bo+=j
print(sum_al-sum_bo)

# Example run
# Input:
5354599
52
# Output:
52
N = int(input())
A = [int(a) for a in input().split()]
A.sort()
A.reverse()
d = 0
for a in A[::2]:
  d += a
for a in A[1::2]:
  d -= a
print(d)


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

# Example run
# Input:
-3471
113
# Output:
113
N = int(input())
list_a = list(map(int, input().split()))

list_a.sort(reverse=True)
Alice_score = sum(list_a[::2])
Bob_score = sum(list_a[1::2])

print(Alice_score - Bob_score)

# Example run
# Input:
59
-18099607
# Output:
-18099607
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:
-19799
-259420352
# Output:
0
# abc088_b.py
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
alice = []
bob = []
for i,v in enumerate(A):
    if i%2==0:
        alice.append(v)
    else:
        bob.append(v)
print(sum(alice)-sum(bob))


# Example run
# Input:
-7038374
-6
# Output:
-6
N = int(input())
cards = list(map(int, input().split()))
A = 0
B = 0
while len(cards) > 0:
  A += max(cards)
  cards.pop(cards.index(max(cards)))
  if len(cards) > 0:
    B += max(cards)
    cards.pop(cards.index(max(cards)))
print(A - B)

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

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

a = sorted(a, reverse = True)
x = []
y = []
ans = 0
flg = 0
for i in a:
    if flg == 0:
        ans +=i
        flg = 1
    else:
        ans -=i
        flg = 0
print(ans)

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

alice_count = 0
bob_count = 0
for i in range(N//2):
  alice_count += max(a)
  a.pop(a.index(max(a)))
  bob_count += max(a)
  a.pop(a.index(max(a)))

if a:
  alice_count += a[0]
  
count = alice_count - bob_count

print(count)

# Example run
# Input:
-17880
665
# Output:
665
#-*-cording:utf-8-*-
N = int(input())
A = input().split()
A.sort()
A.reverse()
print(A)
a=list(map(int,A))
Alice = a[1::2]
Bob = a[0::2]
allA=sum(Alice)
allB=sum(Bob)
Ans=allB-allA
print(Ans)

# Example run
# Input:
43064
-3108573
# Output:
['-3108573']
-3108573
import math
from collections import deque
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq

n = readInt()
a = readInts()
a.sort(reverse=True)
if len(a)%2:
	a.append(0)
alice = 0
bob = 0
for i in range(0,len(a),2):
	alice+=a[i]
	bob+=a[i+1]
print(alice-bob)

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

a.sort(reverse=True)

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

print("{}".format(Alice - Bob))

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

# Example run
# Input:
0
-6956
# Output:
-6956
N = int(input())

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

Alice = 0
Bob = 0

for i in range(N):
  MaxPoint = max(cards)
  
  if i % 2 == 0:
    Alice += MaxPoint
  else:
    Bob   += MaxPoint

  cards.remove(MaxPoint)

print(Alice - Bob)

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

# Example run
# Input:
T~.yFv
4
# Output:
4
n = int(input())
alist = map(int, input().split())
alice = []
bob = []
for i, a in enumerate(sorted(alist, reverse=True)):
    if i % 2 == 0:
        alice.append(a)
    else:
        bob.append(a)
print(sum(alice) - sum(bob))


# Example run
# Input:
-21
-687
# Output:
-687
N = input()
List = map(int, input().split())
nList = sorted(List)[::-1]
print(sum(nList[::2]) - sum(nList[1::2]))

# Example run
# Input:
E(ahj
-2563646
# Output:
-2563646
if __name__ == '__main__':
    _ = input()
    n_list = [int(n) for n in input().split()]
    
    p_alice = 0
    p_bob = 0
    i = 0
    for n in sorted(n_list, reverse=True):
        if i%2 == 0:
            p_alice += n
        else:
            p_bob += n
        i += 1

    print(p_alice - p_bob)

# Example run
# Input:
4_LrU
-185
# Output:
-185
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:
386945
3485
# Output:
['3485']
['3485'] []
3485
n = int(input())
c = list(map(int, input().split()))
d = sorted(c, reverse=True)
print(sum(d[0::2]) - sum(d[1::2]))

# Example run
# Input:
-2
-497
# Output:
-497
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 = Alice + A[i]
    else:
        Bob = Bob + A[i]

ans = (Alice - Bob)

print(ans)

# Example run
# Input:
-6956
-7038374
# Output:
0
N = int(input())
Ai = list(map(int,input().split()))
Alice = 0
Bob = 0
Ai.append(0)

while Ai:
    Alice += max(Ai)
    Ai.remove(max(Ai))
    if not Ai:
        break
    Bob += max(Ai)
    Ai.remove(max(Ai))

print(Alice-Bob)

# Example run
# Input:
313
6462056
# Output:
6462056
N = int(input())
A = list(map(int,input().split()))
B = sorted(A,reverse=True)
x=0
for i in range(0,N,2):
    x = x + B[i] 
for j in range(1,N,2):
    x = x - B[j]
print(x)

  

# Example run
# Input:
0
8131
# Output:
0
N, i = [input() for x in range (2)]
arr = sorted([int(y) for y in i.split(' ')], reverse=True)

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

# Example run
# Input:
QFP`B)go
-1628416575
# Output:
-1628416575
N = int(input())
l = [int(i) for i in input().split()]

l1 = sorted(l, reverse = True)
Alice = 0
Bob = 0
for j in range(len(l)):
    if j % 2 == 0:
        Alice += l1[j]
    else:
        Bob += l1[j]
print(Alice - Bob)

# Example run
# Input:
-4941179
-1
# Output:
-1
N = int(input())
A = [int(x) for x in 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
-14993
# Output:
0
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=1)
print(sum(a[::2])-sum(a[1::2]))

# Example run
# Input:
0
1418198351
# Output:
1418198351
n = int(input())
a = list(map(int, input().split()))
sorted_a = sorted(a, reverse=True)
alice_sum = 0
bob_sum = 0
for i in range(len(sorted_a)):
    if i % 2 == 0:
        alice_sum += sorted_a[i]
    else:
        bob_sum += sorted_a[i]
print(alice_sum - bob_sum)

# Example run
# Input:
155287
-746
# Output:
-746
N = int(input())
M = map(int,input().split())

M = sorted(M,reverse=True)

alice = 0
bob = 0

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

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

arr.sort(reverse=True)

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

# Example run
# Input:
-426204934
-83
# Output:
-83
N = int(input())
lst = sorted([int(x) for x in input().split()], reverse=True)
a = sum([lst[x] for x in range(0, len(lst), 2)])
b = sum([lst[x] for x in range(1, len(lst), 2)])
print(a - b)

# Example run
# Input:
43251559
1792657
# Output:
1792657
N = int(input())
A = list(map(int,input().split()))
A = sorted(A,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:
-68
-31
# Output:
0
N = int(input())
arr = list(map(int, input().split()))
arr.sort(reverse=True)

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

print(alice-bob)


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

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

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


# Example run
# Input:
-2875339
-10855
# Output:
-10855
N = int(input())
a_list = list(map(int, input().split()))

a_list.sort(reverse=True)

Alice = 0
Bob = 0
for num,i in enumerate(a_list):
    if (num+1)%2 != 0:
        Alice+=i
    else:
        Bob+=i
        
print(Alice - Bob)

# Example run
# Input:
-15303
-412794
# Output:
-412794
N=int(input())
a=list(map(int,input().split()))
na=sorted(a)
Alice=0
Bob=0
Alice_turn=0
for i in range(N):
  if Alice_turn%2==0:
    Alice+=na[N-1-i]
    Alice_turn+=1
  else:
    Bob+=na[N-1-i]
    Alice_turn+=1
print(Alice-Bob)

# Example run
# Input:
-161684
-11328633
# 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:
-2701677
-5
# Output:
-5
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

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

diff = A - B
print(diff)

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

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




# Example run
# Input:
-31
-58867430
# Output:
0
n = int(input())
cards = list(map(int, input().split()))
remains = cards.copy()
alice, bob = [], []
while remains:
    a = max(remains)
    alice.append(a)
    remains.remove(a)
    if not remains:
        break
    b = max(remains)
    bob.append(b)
    remains.remove(b)
print(abs(sum(alice) - sum(bob)))

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


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

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

# Example run
# Input:
-151310
-18331
# Output:
-18331
N = int(input())
card_list = [int(n) for n in input().split()]

card_list = sorted(card_list, reverse=True)
point_a = sum(card_list[::2])
point_b = sum(card_list[1::2])
print(point_a - point_b)


# Example run
# Input:
-61684020
84816755
# Output:
84816755
N = int(input())
Arr = list(map(int, input().split()))

Arr.sort(reverse=True)

i = 0
ans = 0
for a in Arr:
  if i%2 == 0:
    ans += a
  else:
    ans -= a
  i += 1

print(ans)


# Example run
# Input:
39756387
-7467726
# Output:
-7467726
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:
5182
0
# Output:
0
n=int(input());
a=list(map(int,input().split()));
a.sort();
s=0;
for i in range(n):s=a[i]-s;
print(s)

# Example run
# Input:
-84521052
-2
# Output:
0
N = int(input())
a = [int(x) for x in input().split()]

a_sum=0
b_sum=0

for i in range((N+1)//2):
    max_value=max(a)
    max_index=a.index(max_value)
    a_sum+=max_value
    a[max_index]=0

    max_value=max(a)
    max_index=a.index(max_value)
    b_sum+=max_value
    a[max_index]=0

print(a_sum-b_sum)


# Example run
# Input:
92
118057
# Output:
118057
n = int(input())
aa = list(map(int, input().split()))
aa.sort(reverse=True)

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


# Example run
# Input:
72046879
23263394
# Output:
23263394
n=int(input())
a = list(map(int,input().split()))
a=sorted(a, reverse = True)
a.append(0)
Alice=Bob=0
for i in range(0,n,2):
    Alice += a[i]
    Bob += a[i+1]
print(Alice-Bob)

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

i = 0
AliceScore = 0
BobScore = 0

while i <= n-1:
    if i % 2 == 0:
        AliceScore += org_list[i]
    else:
        BobScore += org_list[i]
    i += 1

print(AliceScore - BobScore)

# Example run
# Input:
-109089799
-74270783
# Output:
0
# coding: utf-8
n = int(input())
cards = sorted(list(map(int, input().split())), reverse=True)

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

# Example run
# Input:
-2
1973033
# Output:
[1973033]
0
cordcount = int(input())

n = input()
alice = []
bob = []

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

print(x)


alice = x[::-2]

for m in alice:
    x.remove(m)
bob = x
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:
2147483647
71
# Output:
['71']
['71'] []
71
n = int(input())
lis = list(map(int,input().split()))
lis = sorted(lis,reverse = True)
ans = 0
for i in range(n):
 if i % 2 == 0:
  ans += lis[i]
 else:
  ans -= lis[i]
print(ans)

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

# Example run
# Input:
-11385106
-114
# Output:
0
n = input()
a = map(int, input().split())

alice_score = 0
bob_score = 0
for index, i in enumerate(sorted(a, reverse=True)):
    if index % 2 == 0:
        alice_score += i
    else:
        bob_score += i
print(alice_score-bob_score)

# Example run
# Input:
?37ZPS
-58138
# Output:
-58138