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: introductory

Starter code:

Solutions:
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(reverse=True)
alice = 0
bob = 0
for i in range(0,n,2):
    alice += a[i]
    if i == n-1:
        break
    bob += a[i+1]
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 = list(map(int,input().split()))

A = sorted(a,reverse=True)
alice = sum(A[0::2])
bob = sum(A[1::2])

print(alice - 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())
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())
i = list(map(int, input().split()))
i.sort(reverse=True)
print(sum(i[0::2])-sum(i[1::2]))

n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
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))

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)

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())
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 = 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)

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

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)

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()

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

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)))



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 = 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)))

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

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)

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)


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())
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)))

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

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

#!/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))


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 = input()
a = sorted(list(map(int,input().split())),reverse=True)

print((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 = 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)

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))


#!/usr/bin/env python3
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(alice, bob)
    print((sum(alice) - sum(bob)))
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

def __starting_point():
    main()

__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()

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()

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 = 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(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())
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)

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))


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 = 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

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

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)
print((sum(a[::2])-sum(a[1::2])))


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)


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())

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))

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


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))

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())
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))


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]
    elif i%2 == 1 :
        bob += a[i]
print((alice-bob))


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())
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)

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

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)

# coding: utf-8
# Your code here!
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())
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)

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()

N=int(input())
card_list=list(map(int,input().split()))
#各自が自分の数字を最大化するように選択するのが前提なのでAliceが確実に勝つ。
#Aliceは１番目、３番目、５番目、７番目・・・に取っていく
#Bobは２番目、４番目、６番目、８番目・・・に取っていく
#sort関数には、「reverse」という引数が存在します。reverseをTrueに指定することで「降順」を示すことになります。

card_list.sort(reverse=True)
#print(card_list)

card_list_Alice=card_list[::2]
#print(card_list_Alice)
Alice_score=sum(card_list_Alice)
#print(Alice_score)
Bob_score=sum(card_list)-Alice_score
#print(Bob_score)
#Alice_score=card_list[1]+card_list[3]+
#Bob_score=card_list[2]+card_list[4]+

print((Alice_score-Bob_score))


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)

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 = 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)


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())
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())

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)

#!/usr/local/bin/python3
# https://atcoder.jp/contests/abc088/tasks/abc088_b

_ = 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)


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())
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))

n = int(input())
a = [int(i) for i in 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)

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)

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

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 = 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())
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))

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())
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())

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 = 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))

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 = 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))

# coding: utf-8
# Your code here!

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()))
a.sort(reverse = True)
A = 0
B = 0
for i in range(n):
  if i%2 == 0:
    A += a[i]
  else:
    B += a[i]
print(A-B)

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

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


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

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)

n = int(input())
arr = list(map(int, input().split(" ")))

# Sort arr, firstly
arr.sort(reverse=True)

a_arr = []
b_arr = []

for (i, ele) in enumerate(arr):
    # Alice
    if i % 2 == 0:
        a_arr.append(ele)
    # Bob
    else:
        b_arr.append(ele)

print(sum(a_arr) - sum(b_arr))

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)

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]
        #print("alice:"+str(alice))
        flag = 1
    else:
        bob += a[i]
        #print("bob:"+str(bob))
        flag = 0
print(alice - bob)

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 = 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)

def solve1(n, lst):
    alice, bob = 0, 0

    #print(" i |a[i]|Alice|Bob")
    # print("------------------")

    for i in range(n):
        if i % 2 == 0:
            alice += lst[i]
        else:
            bob += lst[i]
        # print(f"{i:3d}|{a[i]:3d}|{alice:5d}|{bob:5d}")

    return alice - bob


n = int(input())
a = list(map(int, input().split(" ")))
a.sort(reverse=True)
print((solve1(n, a)))


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)