We have N cards. A number a_i is written on the i-th card.

Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first.

The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.

-----Constraints-----
 - N is an integer between 1 and 100 (inclusive).
 - a_i \ (1 \leq i \leq N) is an integer between 1 and 100 (inclusive).

-----Input-----
Input is given from Standard Input in the following format:  
N
a_1 a_2 a_3 ... a_N

-----Output-----
Print Alice's score minus Bob's score when both players take the optimal strategy to maximize their scores.

-----Sample Input-----
2
3 1

-----Sample Output-----
2

First, Alice will take the card with 3. Then, Bob will take the card with 1.
The difference of their scores will be 3 - 1 = 2.

Difficulty: EASY

Solutions:
def ans088(N: int, a: str):
	a = list(map(int, a.split()))
	list.sort(a, reverse=True)
	Alice_count = 0
	Bob_count = 0
	for i in range(len(a)):
		if (i + 1) % 2 == 1:
			Alice_count += a[i]
		else:
			Bob_count += a[i]
	return Alice_count - Bob_count
N = int(input())
a = input()
print(ans088(N, a))


def mapt(fn, *args):
	return tuple(map(fn, *args))

def Input():
	return mapt(int, input().split(' '))

def main():
	n = int(input())
	a = sorted(Input(), reverse=True)
	alice = bob = 0
	for i in range(n):
		if i % 2 == 0:
			alice += a[i]
		else:
			bob += a[i]
	print(alice - bob)
main()


_ = int(input())
A = sorted(list(map(int, input().split())))[::-1]
ans = 0
for (i, a) in enumerate(A):
	if i % 2 == 0:
		ans += a
	else:
		ans -= a
print(ans)


input()
al = [int(i) for i in input().split()]
al.sort()
al = al[::-1]
print(sum(al[::2]) - sum(al[1::2]))


input()
s = sorted(list(map(int, input().split())), reverse=True)
print(sum(s[::2]) - sum(s[1::2]))


n = int(input())
x = list(map(int, input().split()))
a = 0
b = 0
x = sorted(x)
for i in range(n):
	if i % 2 == 0:
		a += x.pop()
	else:
		b += x.pop()
print(a - b)


n = int(input())
l = sorted(list(map(int, input().split())), reverse=True)
print(sum(l[0::2]) - sum(l[1::2]))


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


N = int(input())
a = sorted(list(map(int, input().split())))[::-1]
print(sum(a[::2]) - sum(a[1::2]))


input()
(*a,) = sorted(map(int, input().split()))[::-1]
print(sum(a[::2]) - sum(a[1::2]))


n = int(input())
s = sorted(list(map(int, input().split())))[::-1]
print(sum(s[::2]) - sum(s[1::2]))


def max_index(a: list) -> int:
	return a.index(max(a))

def main():
	n = int(input())
	a = list(map(int, input().split()))
	alice_number = 0
	bob_number = 0
	while len(a) > 0:
		alice_number += a.pop(max_index(a))
		if len(a) == 0:
			break
		else:
			bob_number += a.pop(max_index(a))
	print(alice_number - bob_number)

def __starting_point():
	main()
__starting_point()


N = int(input())
A = sorted(list(map(int, input().split(' '))))[::-1]
print(sum(A[::2]) - sum(A[1::2]))


N = int(input())
a = list(map(int, input().split()))
a.sort()
a.reverse()
print(sum(a[::2]) - sum(a[1::2]))


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


n = int(input())
an = list(reversed(sorted(map(int, input().split()))))
print(sum(an[::2]) - sum(an[1::2]))


n = int(input())
n_list = list(map(int, input().split()))
alice = []
bob = []
while n_list != []:
	a = max(n_list)
	alice.append(a)
	n_list.remove(a)
	if n_list == []:
		break
	b = max(n_list)
	bob.append(b)
	n_list.remove(b)
print(sum(alice) - sum(bob))


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


N = input()
card = list(map(int, input().split()))
A = []
B = []
t = 'A'
while card:
	if t == 'A':
		A.append(max(card))
		card.remove(max(card))
		t = 'B'
	else:
		B.append(max(card))
		card.remove(max(card))
		t = 'A'
print(sum(A) - sum(B))


N = int(input())
c = sorted(map(int, input().split()), reverse=True)
print(sum(c[0::2]) - sum(c[1::2]))


n = int(input())
l = sorted(list(map(int, input().split())))[::-1]
print(sum(l[::2]) - sum(l[1::2]))


n = int(input())
a = sorted(map(int, input().split()), reverse=True)
print(sum(a[::2]) - sum(a[1::2]))


N = input()
A = list(map(int, input().split()))
A.sort(reverse=True)
print(sum(A[0::2]) - sum(A[1::2]))


N = int(input())
list1 = list(map(int, input().split()))
list1.sort(reverse=True)
alice = 0
bob = 0
for i in range(len(list1)):
	if i % 2 == 0:
		alice += list1[i]
	else:
		bob += list1[i]
print(alice - bob)


input()
(*A,) = reversed(sorted(map(int, input().split())))
a = sum(A[0::2])
print(2 * a - sum(A))


n = int(input())
L = [int(i) for i in input().split()]
print(2 * sum(sorted(L)[::-2]) - sum(L))


N = int(input())
S = sorted(list(map(int, input().split())))
S.reverse()
print(sum(S[::2]) - sum(S[1::2]))


n = int(input())
a = list(map(int, input().split()))
s_a = sorted(a)[::-1]
print(sum(s_a[::2]) - sum(s_a[1::2]))


n = int(input())
a = sorted(map(int, input().split()))[::-1]
A = sum(a[::2])
B = sum(a[1::2])
print(A - B)


n = int(input())
a = list(map(int, input().split()))
s = 0
a.sort()
s = sum(a[:n:2]) - sum(a[1:n:2])
print(abs(s))


n = int(input())
A = sorted(list(map(int, input().split())))[::-1]
print(sum(A[::2]) - sum(A[1::2]))


n = int(input())
a = sorted(map(int, input().split()))
print(abs(sum(a[::2]) - sum(a[1::2])))


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


(n, *a) = map(int, open(0).read().split())
a = sorted(a)[::-1]
print(sum(a[0::2]) - sum(a[1::2]))


n = int(input())
a = list(map(int, input().split()))
cnt = 0
a.sort(reverse=True)
for i in range(n):
	if i % 2 == 0:
		cnt += a[i]
	else:
		cnt -= a[i]
print(cnt)


def main():
	N = int(input())
	A = list(map(int, input().split()))
	alice = 0
	bob = 0
	A.sort(reverse=True)
	for (i, a) in enumerate(A):
		if i % 2 == 0:
			alice += a
		else:
			bob += a
	print(alice - bob)

def __starting_point():
	main()
__starting_point()


N = int(input())
A = list(map(int, input().split()))
A.sort()
S = 0
T = 0
ans = 0
for i in range(N):
	if N % 2 == 0:
		if i % 2 != 0:
			S += A[i]
		else:
			T += A[i]
		ans = S - T
	else:
		if i % 2 != 0:
			T += A[i]
		else:
			S += A[i]
		ans = S - T
print(ans)


for a in sorted(map(int, [*open((c := 0))][1].split())):
	c = a - c
print(c)


N = int(input())
a = [int(b) for b in 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(str(Alice - Bob))


n = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
print(sum(a[0:n:2]) - sum(a[1:n:2]))


N = int(input())
a = list(map(int, input().split()))
a.sort()
print(abs(sum(a[0::2]) - sum(a[1::2])))


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)


input()
lst = sorted(list(map(int, input().split())))[::-1]
print(sum(lst[::2]) - sum(lst[1::2]))


n = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
A = sum(a[0::2])
B = sum(a[1::2])
print(A - B)


N = int(input())
a = [int(s) for s in input().split()]
a.sort(reverse=True)
print(sum(a[0::2]) - sum(a[1::2]))


N = int(input())
cards = [int(s) for s in input().split()]
list.sort(cards, reverse=True)
a_cards = cards[0::2]
b_cards = cards[1::2]
print(sum(a_cards) - sum(b_cards))


def resolve():
	N = int(input())
	an = sorted([int(n) for n in input().split()], reverse=True)
	print(sum(an[::2]) - sum(an[1::2]))

def __starting_point():
	resolve()
__starting_point()


from typing import List

def answer(n: int, a: List[int]) -> int:
	alice = 0
	bob = 0
	a.sort(reverse=True)
	for i in range(0, len(a), 2):
		alice += a[i]
	for j in range(1, len(a), 2):
		bob += a[j]
	return abs(alice - bob)

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

def __starting_point():
	main()
__starting_point()


input()
s = sorted(map(int, input().split()))[::-1]
print(abs(sum(s[::2]) - sum(s[1::2])))


n = int(input())
cards = list(map(int, input().split()))
cards = sorted(cards, reverse=True)
alice = bob = 0
for i in cards[::2]:
	alice += i
for j in cards[1::2]:
	bob += j
print(alice - bob)


input()
l = sorted([int(_) for _ in input().split()])[::-1]
print(sum(l[::2]) - sum(l[1::2]))


n = int(input())
a = list(map(int, input().split()))
a.sort()
s = 0
for i in range(n):
	s = a[i] - s
print(s)


n = int(input())
list_a = sorted([int(i) for i in input().split()], reverse=True)
ans = 0
for i in range(0, len(list_a)):
	if i % 2 == 0:
		ans += list_a[i]
	else:
		ans -= list_a[i]
print(ans)


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


n = input()
a = [int(x) for x in input().split()]
a.sort(reverse=True)
print(sum(a[::2]) - sum(a[1::2]))


n = int(input())
a = list(map(int, input().split()))
a.sort()
A = []
B = []
for i in range(1, n + 1):
	if i % 2 != 0:
		A.append(a[-i])
	else:
		B.append(a[-i])
print(sum(A) - sum(B))


(_, *a) = map(int, open(0).read().split())
a.sort()
print(sum(a[-1::-2]) - sum(a[-2::-2]))


n = int(input())
aa = list(sorted(map(int, input().split())))
print(abs(sum(aa[::2]) - sum(aa[1::2])))


n = int(input())
lst = sorted(list(map(int, input().split())))
print(abs(sum(lst[1::2]) - sum(lst[0::2])))


n = int(input())
a = [int(n) for n in input().split(' ')]
a.sort()
print(sum(a[::-2]) - sum(a[-2::-2]))


(n, *a) = map(int, open(0).read().split())
a.sort(reverse=True)
print(sum(a[0::2]) - sum(a[1::2]))


import sys
lines = [s.rstrip('\n') for s in sys.stdin.readlines()]
(n,) = [int(num) for num in lines.pop(0).split(' ')]
a_list = [int(num) for num in lines.pop(0).split(' ')]
a_list.sort(reverse=True)
alice_sum = sum((a_list[i] for i in range(0, n, 2)))
bob_sum = sum(a_list) - alice_sum
print(alice_sum - bob_sum)


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


n = input()
a = sorted(map(int, input().split()))
print(sum(a[::-2]) - sum(a[-2::-2]))


import sys
(n, *a) = map(int, sys.stdin.read().split())
a.sort(reverse=True)
print(sum(a[::2]) - sum(a[1::2]))


_ = input()
l = list(map(int, input().split()))
l.sort()
l.reverse()
print(sum(l[::2]) - sum(l[1::2]))


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


input()
lis = sorted(list(map(int, input().split())), reverse=True)
print(sum(lis[0::2]) - sum(lis[1::2]))


N = input()
a = list(map(int, input().split()))
a.sort(reverse=True)
A = a[::2]
B = a[1::2]
print(sum(A) - sum(B))


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)


input()
c = 0
for a in sorted(map(int, input().split())):
	c = a - c
print(c)


N = int(input())
A = sorted(map(int, input().split()), reverse=True)
print(sum(A[::2]) - sum(A[1::2]))


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, 2))
N_Odd = list(range(1, N, 2))
a1 = sort_reverse(a)
sum1 = 0
sum2 = 0
for i in N_Even:
	sum1 += a1[i]
for j in N_Odd:
	sum2 += a1[j]
print(sum1 - sum2)


n = int(input())
arr = list(map(int, input().split(' ')))
arr.sort(reverse=True)
a_arr = []
b_arr = []
for (i, ele) in enumerate(arr):
	if i % 2 == 0:
		a_arr.append(ele)
	else:
		b_arr.append(ele)
print(sum(a_arr) - sum(b_arr))


_ = input()
a = sorted(map(int, input().split()), reverse=True)
print(sum(a[0::2]) - sum(a[1::2]))


n = int(input())
a = list(map(int, input().split()))
alice = 0
bob = 0
a.sort(reverse=True)
for i in range(0, n, 2):
	alice += a[i]
for i in range(1, n, 2):
	bob += a[i]
print(alice - bob)


N = int(input())
A = list(map(int, input().split()))
A.sort()
x = sum(A[-1::-2])
y = sum(A[-2::-2])
print(x - y)


N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
sum1 = 0
sum2 = 0
for num in range(N):
	if num % 2 == 0:
		sum1 += A[num]
	else:
		sum2 += A[num]
print(sum1 - sum2)


N = int(input())
a = list(map(int, input().split()))
card = list(a)
card.sort(reverse=True)
Alice = []
Bob = []
if len(card) % 2 != 0:
	Alice.append(card[-1])
	card.pop(-1)
while card:
	Alice.append(card[0])
	Bob.append(card[1])
	card.pop(0)
	card.pop(0)
print(sum(Alice) - sum(Bob))


n = int(input())
c = list(map(int, input().split()))
c.sort(reverse=True)
a = 0
b = 0
if n % 2 == 0:
	for i in range(n // 2):
		a += c[i * 2]
		b += c[i * 2 + 1]
else:
	for i in range(n // 2):
		a += c[i * 2]
		b += c[i * 2 + 1]
	a += c[n - 1]
print(a - b)


n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
Alice = 0
Bob = 0
count = 0
while True:
	Alice += a[count]
	count += 1
	if count == n:
		print(Alice - Bob)
		return
	Bob += a[count]
	count += 1
	if count == n:
		print(Alice - Bob)
		return


(_, s) = open(0)
c = 0
for a in sorted(map(int, s.split())):
	c = a - c
print(c)


input()
a = list(map(int, input().split()))
a.sort()
a = a[::-1]
print(sum(a[::2]) - sum(a[1::2]))


n = int(input())
a = list(map(int, input().split()))
Alice = []
Bob = []
a.sort()
a.reverse()
for x in range(n):
	if x % 2 == 0:
		Alice.append(a[x])
	else:
		Bob.append(a[x])
print(sum(Alice) - sum(Bob))


_ = input()
aN = [int(x) for x in input().split()]
aN.sort(reverse=True)
print(sum(aN[::2]) - sum(aN[1::2]))


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


_ = input()
a = [int(i) for i in input().split()]
a.sort()
a.reverse()
print(sum(a[::2]) - sum(a[1::2]))


N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
alice = 0
for i in range(0, N, 2):
	alice += a[i]
bob = sum(a) - alice
print(alice - bob)


n = int(input())
al = sorted(list(map(int, input().split())), reverse=True)
print(sum(al[::2]) - sum(al[1::2]))


n = int(input())
a = list(map(int, input().split()))
alice = 0
bob = 0
a_sort = sorted(a, reverse=True)
for i in range(n):
	if i % 2 == 0:
		alice += a_sort[i]
	else:
		bob += a_sort[i]
print(alice - bob)


_ = int(input())
a = sorted(list(map(int, input().split())))[::-1]
print(sum(a[::2]) - sum(a[1::2]))


N = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
Alice = sum([a[i] for i in range(N) if i % 2 == 0])
Bob = sum([a[i] for i in range(N) if i % 2 == 1])
print(Alice - Bob)


(N, *A) = map(int, open(0).read().split())
A.sort(reverse=True)
print(sum(A[::2]) - sum(A[1::2]))


N = int(input())
a = list(map(int, input().split()))
A = sorted(a, reverse=True)
alice = sum(A[0::2])
bob = sum(A[1::2])
print(alice - bob)


i = input()
l = list(map(int, input().split()))
dl = list(sorted(l))
dl = list(reversed(dl))
ans = 0
for i in range(len(dl)):
	if i % 2 == 0:
		ans += dl[i]
	else:
		ans -= dl[i]
print(ans)


n = int(input())
a = [int(x) for x in input().split()]
a.sort(reverse=True)
res = 0
for i in range(n):
	if i % 2 == 0:
		res += a[i]
	else:
		res -= a[i]
print(res)


N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
Alice_point = 0
Bob_point = 0
for i in range(N):
	if i % 2 == 0:
		Alice_point += a[0]
		a.pop(0)
	else:
		Bob_point += a[0]
		a.pop(0)
print(Alice_point - Bob_point)


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)


input()
A = sorted(map(int, input().split()))[::-1]
print(sum(A[::2]) - sum(A[1::2]))


import numpy as np
n = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
a = np.array(a)
num_i_even = [i for i in range(n) if i % 2 == 0]
num_i_odd = [i for i in range(n) if i % 2 != 0]
sum1 = np.sum(a[num_i_even])
sum2 = np.sum(a[num_i_odd])
print(sum1 - sum2)


input()
a = list(reversed(sorted([int(i) for i in input().split()])))
print(sum(a[::2]) - sum(a[1::2]))


N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
print(sum(A[0::2]) * 2 - sum(A))


N = int(input())
s = sorted(list(map(int, input().split())))
print(abs(sum(s[:N:2]) - sum(s[1:N:2])))


n = int(input())
ai = list(map(int, input().split()))
ai_sort = sorted(ai, reverse=True)
alice = ai_sort[::2]
print(sum(alice) - (sum(ai) - sum(alice)))


n = int(input())
a = list(map(int, input().split()))
s = 0
a.sort()
s = sum(a[:n:2]) - sum(a[1:n:2])
if s > 0:
	print(s)
else:
	print(-s)


N = int(input())
a = list(map(int, input().split()))
a.sort()
a.reverse()
alice = 0
bob = 0
for i in range(N):
	if i % 2 == 0:
		alice += a[i]
	else:
		bob += a[i]
print(alice - bob)


N = input()
li = list(map(int, input().split()))
li.sort(reverse=True)
Alice = 0
Bob = 0
for i in range(len(li)):
	if (i + 1) % 2 == 1:
		Alice += li[i]
	if (i + 1) % 2 == 0:
		Bob += li[i]
print(Alice - Bob)


n = int(input())
(*a,) = map(int, input().split())
a.sort(reverse=True)
A = a[::2]
B = a[1::2]
print(sum(A) - sum(B))


n = int(input())
i = list(map(int, input().split()))
i.sort(reverse=True)
print(sum(i[0::2]) - sum(i[1::2]))


import sys

def solve(N: int, a: 'List[int]'):
	a = list(reversed(sorted(a)))
	alice = [a_[1] for a_ in enumerate(a) if a_[0] % 2 == 0]
	bob = [a_[1] for a_ in enumerate(a) if a_[0] % 2 == 1]
	print(sum(alice) - sum(bob))
	return

def main():

	def iterate_tokens():
		for line in sys.stdin:
			for word in line.split():
				yield word
	tokens = iterate_tokens()
	N = int(next(tokens))
	a = [int(next(tokens)) for _ in range(N)]
	solve(N, a)

def __starting_point():
	main()
__starting_point()


(n, *x) = map(int, open(0).read().split())
a = 0
t = 1
x.sort()
while x:
	a += t * x.pop()
	t *= -1
print(a)


n = int(input())
a = list(map(int, input().split()))
al = []
bb = []
a.sort(reverse=True)
for i in range(n):
	if i % 2 == 1:
		bb.append(a[i])
	else:
		al.append(a[i])
print(sum(al) - sum(bb))


N = int(input())
a_lst = list(map(int, input().split()))
a_lst.sort(reverse=True)
A_a_lst = []
B_a_lst = []
for i in range(N):
	if i % 2 == 0:
		A_a_lst.append(a_lst[i])
	else:
		B_a_lst.append(a_lst[i])
A_sum = sum(A_a_lst)
B_sum = sum(B_a_lst)
ans = A_sum - B_sum
print(ans)


n = int(input())
A = list(map(int, input().split()))
sum_a = 0
sum_b = 0
sorted_A = sorted(A, reverse=True)
flag = 1
for i in sorted_A:
	if flag == 1:
		sum_a += i
		flag = 0
	else:
		sum_b += i
		flag = 1
print(sum_a - sum_b)


N = int(input())
A = list(map(int, input().split()))
Alice = 0
Bob = 0
for i in range(N):
	maxA = max(A)
	A.remove(maxA)
	if i % 2 == 0:
		Alice += maxA
	else:
		Bob += maxA
print('{}'.format(Alice - Bob))


input()
l = sorted(list(map(int, input().split())))
print(sum(l[::-2]) - sum(l[-2::-2]))


(N, A) = open(0)
A = sorted(map(int, A.split()))
print(sum(A[::-2]) - sum(A[-2::-2]))


n = int(input())
ans = 0
A = sorted(list(map(int, input().split())))[::-1]
for i in range(n):
	if i % 2 == 0:
		ans += A[i]
	else:
		ans -= A[i]
print(ans)


n = int(input())
c = sorted(map(int, input().split()))[::-1]
a = sum(c[::2])
b = sum(c[1::2])
print(a - b)


input()
l = sorted(map(int, input().split()))[::-1]
print(sum(l[::2]) - sum(l[1::2]))


n = int(input())
ai = list(map(int, input().split()))
ai_sort = sorted(ai)
alice = []
for i in range(-1, -n - 1, -2):
	alice.append(ai_sort[i])
print(sum(alice) - (sum(ai) - sum(alice)))


I = input
(N, A) = (I(), list(map(int, I().split())))
A.sort()
print(sum(A[-1::-2]) - sum(A[-2::-2]))


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)


N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
Alice = 0
Bob = 0
flag = True
for i in a:
	if flag == True:
		Alice += i
		flag = False
	else:
		Bob += i
		flag = True
print(Alice - Bob)


N = int(input())
lst = input().split()
for i in range(N):
	lst[i] = int(lst[i])
lst.sort(reverse=True)
Alice = 0
Bob = 0
for i in range(N // 2):
	Alice += lst[2 * i]
	Bob += lst[2 * i + 1]
if N % 2 == 1:
	Alice += lst[-1]
print(Alice - Bob)


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)


with open(0) as f:
	(N, *A) = map(int, f.read().split())
A.sort(reverse=True)
Alice = sum(A[::2])
Bob = sum(A[1::2])
print(Alice - Bob)


N = int(input())
A = sorted([int(i) for i in input().split()], reverse=True)
print(sum(A[0::2]) - sum(A[1::2]))


n = int(input())
a = list(map(int, input().split()))
a.sort()
a.reverse()
print(sum(a[0::2]) * 2 - sum(a))


n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
Alice = sum(a[::2])
Bob = sum(a[1::2])
print(Alice - Bob)


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

class Solution:

	def __init__(self, n, an):
		self.n = n
		self.an = an

	@staticmethod
	def __reverse_an():
		r_an = sorted(an, reverse=True)
		return r_an

	def answer(self):
		r_an = self.__reverse_an()
		ans = 0
		for (index, r_ai) in enumerate(r_an):
			if index % 2 == 0:
				ans += r_ai
			else:
				ans -= r_ai
		print(ans)
conditions = Solution(n, an)
conditions.answer()


N = int(input())
card_list = list(map(int, input().split()))
card_list.sort(reverse=True)
card_list_Alice = card_list[::2]
Alice_score = sum(card_list_Alice)
Bob_score = sum(card_list) - Alice_score
print(Alice_score - Bob_score)


N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
flag = 0
alice = 0
bob = 0
for i in range(N):
	if flag == 0:
		alice += a[i]
		flag = 1
	else:
		bob += a[i]
		flag = 0
print(alice - bob)


N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
alice = 0
bob = 0
tf = True
for i in a:
	if tf:
		alice += i
	else:
		bob += i
	tf = not tf
print(alice - bob)


N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
(Alice, Bob) = (0, 0)
for i in range(N):
	if i % 2 == 0:
		Alice += a[i]
	else:
		Bob += a[i]
print(Alice - Bob)


input()
List = sorted(list(map(int, input().split())))[::-1]
print(sum(List[0::2]) - sum(List[1::2]))


N = int(input())
(*A,) = map(int, input().split())
A.sort()
print(sum(A[::-2]) - sum(A[-2::-2]))


N = int(input())
C = list(map(int, input().split()))
Alice = []
Bob = []
C = sorted(C, reverse=True)
for i in range(0, N):
	if i % 2 == 0:
		Alice.append(C[i])
	else:
		Bob.append(C[i])
print(sum(Alice) - sum(Bob))


input()
card = sorted(map(int, input().split()))[::-1]
print(sum(card[::2]) - sum(card[1::2]))


n = int(input())
all_cards = list(map(int, input().split()))
all_cards.sort(reverse=True)
alice_cards = []
bob_cards = []
for i in range(n):
	if i % 2 == 0:
		alice_cards.append(all_cards[i])
	if i % 2 == 1:
		bob_cards.append(all_cards[i])
print(sum(alice_cards) - sum(bob_cards))


def solve1(n, lst):
	(alice, bob) = (0, 0)
	for i in range(n):
		if i % 2 == 0:
			alice += lst[i]
		else:
			bob += lst[i]
	return alice - bob
n = int(input())
a = list(map(int, input().split(' ')))
a.sort(reverse=True)
print(solve1(n, a))


N = input()
ai = sorted(map(int, input().split()))[::-1]
print(sum(ai[::2]) - sum(ai[1::2]))


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)


n = int(input())
a = sorted([int(i) for i in input().split()])[::-1]
print(sum(a[::2]) - sum(a[1::2]))


(n, a) = open(0)
l = sorted(map(int, a.split()))
l1 = l[0:][::2]
l2 = l[1:][::2]
print(abs(sum(l1) - sum(l2)))


n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
a = 0
b = 0
zyu = 0
for i in l:
	if zyu == 0:
		a += i
		zyu = 1
	else:
		zyu = 0
		b += i
if a < b:
	print(b - a)
elif a > b:
	print(a - b)
else:
	print('0')


n = int(input())
lst = list(map(int, input().split()))
alice = 0
bob = 0
lst.sort()
for i in range(n):
	if i % 2 == 0:
		alice += lst.pop()
	else:
		bob += lst.pop()
print(alice - bob)


N = int(input())
A = list(map(int, input().split()))
Alice = 0
Bob = 0
while len(A) != 0:
	Alice += max(A)
	A.remove(max(A))
	if len(A) == 0:
		break
	Bob += max(A)
	A.remove(max(A))
	if len(A) == 0:
		break
print(Alice - Bob)


N = int(input())
nums = [int(s) for s in input().split()]
nums = sorted(nums, reverse=True)
Alice = 0
Bob = 0
i = 0
while nums:
	if i % 2 == 0:
		Alice += nums.pop(0)
	else:
		Bob += nums.pop(0)
	i += 1
print(Alice - Bob)


N = int(input())
A = list(map(int, input().split()))
A.sort()
Alice = 0
Bob = 0
while 1:
	try:
		Alice += A.pop(-1)
	except IndexError:
		break
	try:
		Bob += A.pop(-1)
	except IndexError:
		break
print(Alice - Bob)


n = int(input())
a = list(map(int, input().split()))
sa = sorted(a, reverse=True)
al = 0
bo = 0
for i in range(n):
	if i % 2 == 0:
		al += sa[i]
	else:
		bo += sa[i]
print(al - bo)


getint = lambda : int(input())
getints = lambda : map(int, input().split())
getlist = lambda : list(getints())
n = getint()
a = getlist()
a.sort(reverse=True)
alice = bob = 0
for i in range(n):
	if i % 2:
		bob += a[i]
	else:
		alice += a[i]
print(alice - bob)


N = int(input())
nums = list(map(int, input().split()))
nums.sort(reverse=True)
Alice = []
Bob = []
i = 0
if N % 2 == 0:
	while i <= N - 1:
		Alice.append(nums[i])
		Bob.append(nums[i + 1])
		i += 2
else:
	while i <= N - 2:
		Alice.append(nums[i])
		Bob.append(nums[i + 1])
		i += 2
	Alice.append(nums[N - 1])
sum_allice = sum(Alice)
sum_bob = sum(Bob)
answer = sum_allice - sum_bob
print(answer)


N = int(input())
A = list((int(x) for x in input().split()))
A.sort(reverse=True)
ans = 0
for i in range(N):
	a = A[i]
	if i % 2 == 0:
		ans += a
	else:
		ans -= a
print(ans)


N = int(input())
a = sorted(map(int, input().split()))
print(abs(sum(a[1::2]) - sum(a[::2])))


n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
num = len(a)
alice = []
bob = []
coun = 1
for i in a:
	if coun % 2 == 1:
		alice.append(i)
	else:
		bob.append(i)
	coun += 1
ans = abs(sum(alice) - sum(bob))
print(ans)


N = input()
a = sorted([int(j) for j in input().split()], reverse=True)
print(sum(a[::2]) - sum(a[1::2]))


input()
print(sum((-k if i % 2 else k for (i, k) in enumerate(sorted(map(int, input().split()), reverse=True)))))


input()
[print(sum(A[::2]) - sum(A[1::2])) for A in [sorted(map(int, input().split()), reverse=True)]]


def main():
	n = int(input())
	cards = list(map(int, input().split()))
	cards.sort(reverse=True)
	(alice, bob) = (0, 0)
	if n % 2 == 0:
		for i in range(int(n / 2)):
			alice += cards[2 * i]
			bob += cards[2 * i + 1]
	else:
		for j in range(int(n / 2)):
			alice += cards[2 * j]
			bob += cards[2 * j + 1]
		alice += cards[n - 1]
	ans = alice - bob
	print(ans)

def __starting_point():
	main()
__starting_point()