Problem:
 Score: 200 points    Problem Statement  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 1 2
3 1      Sample Output 1 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 .       Sample Input 2 3
2 7 4      Sample Output 2 5  First, Alice will take the card with 7 . Then, Bob will take the card with 4 . Lastly, Alice will take the card with 2 . The difference of their scores will be 7 - 4 + 2 = 5 . The difference of their scores will be 3 - 1 = 2 .       Sample Input 3 4
20 18 2 18      Sample Output 3 18

Solution (Python):
import sys
input = sys.stdin.readline

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

Solution (Python):
n=int(input())
la=sorted(list(map(int, input().split())),reverse=True)
a=b=0
for i in range(0,n,2):
    a+=la[i]
for i in range(1,n,2):
    b+=la[i]
print(abs(b-a))

Solution (Python):
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)

Solution (Python):

N = int(input())
x = list(map(int,input().split()))
alis = 0
bob = 0
cou = 0

x.sort()

for i in reversed(range(N)):
    if cou %2 == 0:
        alis += x[i]
    else:
        bob += x[i]
    cou += 1

print(alis - bob)

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

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

Solution (Python):
N = int(input())
a = sorted(list(map(int, input().split())), reverse=True)

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

print(alice - bob)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)

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

print(alice - bob)

Solution (Python):
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)

Solution (Python):
N = int(input())
c_list = sorted(list(map(int,input().split())),reverse = True)
a = 0
b = 0

for i in range(1,len(c_list) + 1):
    if i % 2 == 0:
        b += c_list[i-1]
    else: 
        a += c_list[i-1]
print(a-b )

Solution (Python):
N = int (input ())
L = input ().split ()
l = [int(s) for s in L]
list.sort (l, reverse=True)
a = 0
x = 0
y = 0
while True:
    x += int (l[a])
    a += 1
    if a == N:
        break
    y += int (l[a])
    a += 1
    if a == N:
        break
print (x-y)

Solution (Python):


n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
    
alice = 0
bob = 0
for i, value in enumerate(a):
  if i % 2 == 0:
    alice += value
  else:
    bob += value

print(alice - bob)

Solution (Python):
N = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
print(sum([a[i] for i in range(0,N,2)]) - sum([a[i] for i in range(1,N,2)]))

Solution (Python):
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)

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

Solution (Python):

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

al = 0
bo = 0

for i in range(len(a)):
    if i % 2 == 1:
        bo += a[i]
    else:
        al += a[i]

print(al - bo)

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

Solution (Python):
def main():
    N = int(input())
    a = sorted([int(x) for x in input().split(" ")], reverse=True)
    Alice = sum([x for i, x in enumerate(a) if i % 2 == 0])
    Bob = sum([x for i, x in enumerate(a) if i % 2 == 1])
    print(Alice-Bob)


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
l = list(map(int, input().split()))
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)

Solution (Python):
N=int(input())
a=list(map(int, input().split()))
a.sort()
a=a[::-1]
A=sum([a[i] for i in range(0, N, 2)])
B=sum([a[i] for i in range(1, N, 2)])
print(A-B)

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

Solution (Python):
N = int(input())
a = list(map(int,input().split()))
a.sort(reverse = True)
Alice = 0
Bob = 0
i = 0
while i < N:
  Alice += a[i]
  i += 1 
  if i >= N:
    break
  Bob += a[i]
  i += 1
  
print(Alice - Bob)

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

Solution (Python):
n = int(input())
array = list(map(int, input().split()))

bob = []
alice = []
for i in range(1, n+1):
    max_value = max(array)
    if i % 2 == 1:
        alice.append(max_value)
    else:
        bob.append(max_value)
    array.remove(max_value)

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

Solution (Python):
def resolve():
    N = int(input())
    A = list(reversed(sorted([int(i) for i in input().split(maxsplit=N)])))
    print(sum(A[0::2]) - sum(A[1::2]))


resolve()

Solution (Python):
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt, gcd
from copy import deepcopy
from functools import reduce



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

    print(a-b)

if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
A = 0
B = 0
for i in range(0, N, 2):
    A += a[i]
for i in range(1, N, 2):
    B += a[i]
print(A - B)

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

Solution (Python):
"""abc088_b"""
N = int(input())
A = list(map(int, input().split()))

a_desc = sorted(A, reverse=True)
print(sum(a_desc[0::2])-sum(a_desc[1::2]))

Solution (Python):
"""abc088_b"""
N = int(input())
A = list(map(int, input().split()))

alice = 0
bob = 0

a_desc = sorted(A, reverse=True)

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

print(alice - bob)

Solution (Python):
import math
def main():
  n = int(input())
  a = list(map(int,input().split()))
  a.sort(reverse=True)
  alice=sum(a[::2])
  bob=sum(a[1::2])
  print(alice-bob)
main()

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse = True)

alice = 0
bob = 0
count = 0

for i in range(0, len(a)):
	if count % 2 == 0:
		alice += a.pop(0)
	elif count % 2 == 1:
		bob += a.pop(0)
	count += 1

print(alice - bob)

Solution (Python):
N = int(input())
A = [int(a) for a in input().split()]
A = sorted(A)

alice = 0
bob = 0

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

print(alice - bob)

Solution (Python):
N = int(input())
cards = list(map(int, input().split()))
cards.sort(reverse = True)
score_A = 0
score_B = 0
for i in range(len(cards)):
  if i%2 == 0:
    score_A += cards[i]
  else :
    score_B += cards[i]
print(score_A - score_B)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

A = sorted(A, reverse=True)
print(sum(A[::2])-sum(A[1::2]))

Solution (Python):
def resolve():
    '''
    code here
    '''
    N = int(input())
    As = [int(item) for item in input().split()]
    As = sorted(As)

    turn = 0
    A = 0
    B = 0
    while As:
        if turn % 2 == 0:
            A += As.pop()
        else:
            B += As.pop()

        turn += 1
    print(A-B)




if __name__ == "__main__":
    resolve()

Solution (Python):
import sys
N = int(input())
array = list(map(int,input().split()))
sys.exit() if not (1 <= N <= 100) else ''
for I in range(len(array)):
    sys.exit() if not (1 <= array[I] <= 100) else ''

array.sort(reverse=True)
alice = 0
bob = 0
for J in range(len(array)):
    if J == 0 or J % 2 == 0:
        alice += array[J]
    else:
        bob += array[J]

print(alice - bob)

Solution (Python):

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


res = 0
Alice_Turn = True
while A:
    max_a = max(A)
    if Alice_Turn:
        res += max_a
        Alice_Turn = False
    else:
        res -= max_a
        Alice_Turn = True
    A.remove(max_a)

print(res)

Solution (Python):
n=int(input())
a=map(int,input().split())
lis=list(a)
lis.sort()
ali=0
bob=0
for i in range(n):
  if i%2==0:
    ali+=lis.pop()
  else:
    bob+=lis.pop()
print(ali-bob)

Solution (Python):
n=int(input())

a_list=[int(i) for i in input().split()]
a_list.sort(reverse=True)


alice=[]
bob=[]
for i in range(n):
    if i%2==0:
        alice.append(a_list[i])
    else:
        bob.append(a_list[i])
        
print(sum(alice)-sum(bob))

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

Solution (Python):
n = int(input())
l = sorted(list(map(int, input().split())), reverse=True)

alice_sum = 0
bob_sum = 0
for i in range(n):
  if i% 2 == 0:
    alice_sum += l[i]
  else:
    bob_sum += l[i]

print(alice_sum - bob_sum)

Solution (Python):










import sys

def input(): return sys.stdin.readline()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip('\n') for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]

def OutH(lst, deli=' '): print(deli.join(map(str, lst)))
def OutV(lst): print('\n'.join(map(str, lst)))

sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)


N = iIn()
A = iInLH()

A.sort(reverse=True)

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

print(ans)

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

a.sort(reverse=True)

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

print(result)

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

a.sort(reverse=True)

Alice, Bob = 0, 0
for i in a[::2]:
    Alice += i
    
for i in a[1::2]:
    Bob += i

result = Alice - Bob

print(result)

Solution (Python):
def actual(N, A):
    A_desc = sorted(A, reverse=True)

    alice_cards = A_desc[::2]
    bob_cards = A_desc[1::2]

    return sum(alice_cards) - sum(bob_cards)

N = int(input())
A = map(int, input().split())

print(actual(N, A))

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

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
""" 
print(a) """

alice=0
bob=0
a.sort(reverse=True)
alice = [a[i]for i in range(n) if i%2==0]
bob=[a[i]for i in range(n) if i%2==1 ]
print(sum(alice)-sum(bob))
""" for i in range(n):
    if i%2==0:
        alice+=a[i]
    else:
        bob+=a[i] """

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
""" 
print(a) """

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

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

a.sort(reverse=True)

A,B=0,0

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

print(A-B)

Solution (Python):
n = int(input())
a = map(int,input().split())

point_Alice = 0
point_Bob = 0

b = sorted(a,reverse=True)

while True:
    point_Alice += b.pop(0)
    if b == []:
        break
    point_Bob += b.pop(0)
    if b == []:
        break

ans = point_Alice - point_Bob
print(ans)

Solution (Python):






N = int(input().strip())
An = list(map(int, input().strip().split()))

An = sorted(An, reverse=True)

p1 = sum(An[0::2])
p2 = sum(An[1::2])

print(p1 - p2)

Solution (Python):
n = int(input())
lis = list(map(int, input().split()))

lis = sorted(lis, reverse = True)

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

print(a-b)

Solution (Python):
n = int(input())
l = list(map(int, input().split()))
L = sorted(l, reverse=True)
a = 0
b = 0
for i in range(n):
  if i % 2 == 0:
    a = L[i] + a
  else:
    b = L[i] + b
print(a-b)

Solution (Python):
n, *aa = map(int, open(0).read().split())

aa.sort(reverse=True)

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ali = 0
bob = 0
a.sort()
a.reverse()

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

print(ali - bob)

Solution (Python):
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)

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

Solution (Python):
N = int(input())
a = []
a = input().split(' ')
a = [int(i) for i in a]
a = sorted(a, reverse=True)
Alice = 0
Bob = 0
for i in range(N):
  if i == 0:
    Alice += a[i]
  elif i%2 == 0:
    Alice += a[i]
  elif i%2 == 1:
    Bob += a[i]

print(Alice - Bob)

Solution (Python):
N = int(input())
a = []
a = input().split(' ')
a = [int(i) for i in a]
a = sorted(a, reverse=True)
Alice = 0
Bob = 0
for i in range(N):
  if i == 0:
    Alice += a[i]
  elif i%2 == 0:
    Alice += a[i]
  elif i%2 == 1:
    Bob += a[i]

print(Alice - Bob)

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

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

X=0
k=1
for a in A:
    X+=k*a
    k*=-1
print(X)

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

a.sort()
a.reverse()
print(sum([a[i] if i % 2 == 0 else -a[i] for i in range(n)]))

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

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

Solution (Python):
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    N = II()
    A = LMIIS()
    A.sort(reverse=True)
    alice = sum(A[0::2])
    bob = sum(A[1::2])
    print(alice-bob)
    
main()

Solution (Python):
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)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
k=0
l=0

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

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
res = 0
for i in range(N - 1, -1, -2):
    res += A[i]
for i in range(N - 2, -1, -2):
    res -= A[i]
print(res)

Solution (Python):










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

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

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

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

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

Solution (Python):
n = int(input())
l = list(map(int,input().split()))
l.sort(reverse=True)
alice = sum(l[0::2])
bob = sum(l[1::2])
print(alice-bob)

Solution (Python):
N = int(input())
a_list = [int(i) for i in input().split()]

ans = 0
flag = True
for a in sorted(a_list, reverse=True):
    if flag:
        ans += a
    else:
        ans -= a
    flag = not flag
print(ans)

Solution (Python):
N = int(input())
a_list = [int(i) for i in input().split()]

alice = 0
bob = 0
flag = True
for a in sorted(a_list, reverse=True):
    if flag:
        alice += a
    else:
        bob += a
    flag = not flag
print(alice-bob)

Solution (Python):
import sys
input = sys.stdin.readline
n = int(input())
a_li = [int(w) for w in input().split()]
a_li.sort(reverse=True)

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

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

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

Solution (Python):
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))

Solution (Python):
N, *a = map(int, open(0).read().split())

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

Solution (Python):
N = int(input())

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

a.sort(reverse=True)

i = 0
A = 0
B = 0

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

print(A - B)

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

Solution (Python):
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)

Solution (Python):
import numpy as np
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
a = np.array(a)
alice = a[0::2]
bob = a[1::2]
print(sum(alice)-sum(bob))

Solution (Python):
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort(reverse=True)

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

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)

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

print(alice - bob)

Solution (Python):
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)

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

print(p1-p2)

Solution (Python):
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)

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

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
A = sorted(A,reverse = True)
A.insert(N,0)
ans = 0
for i in range(0,N,2):
	ans += (A[i] - A[i+1])
print(ans)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
A = sorted(A,reverse = True)
A.insert(N,0)
ans = 0
for i in range(0,N,2):
	ans += (A[i] - A[i+1])
print(ans)

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

a.sort(reverse=True)

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

Solution (Python):
N = int(input())
cards = list(map(int, input().split()))
cards.sort(reverse=True)

Alice = 0
Bob = 0
for i, card in enumerate(cards):
    if i % 2 == 0:
        Alice += card
    else:
        Bob += card
print(Alice - Bob)

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

Solution (Python):
import math
from sys import stdin
data = stdin.readlines()

a = int(data[0])
b = [int(s) for s in data[1].split()]

i = 1
alice = 0
bob = 0
while i <= math.ceil(a/2):
    alice += b.pop(b.index(max(b)))
    if len(b) >= 1:
        bob  += b.pop(b.index(max(b)))
    i += 1
print(alice - bob)

Solution (Python):
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)

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

a, b = 0, 0
for i in range(N):
    if i % 2 == 0:
        a += A.pop(0)
    else:
        b += A.pop(0)

print(a-b)

Solution (Python):
n = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
alc = 0
bb = 0
for i in range(0, n, 2):
    alc += A[i]
for j in range(1, n, 2):
    bb += A[j]
print(alc - bb)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
alice = A[::2]
bob = A[1::2]

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort()

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

print(alice-bob)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a.sort() 
alice_sum=0
bob_sum=0
if len(a)%2==0:
  for i in range(0,n,2):
    bob_sum+=a[i]
  for l in range(1,n,2):
    alice_sum+=a[l]
else:
  for i in range(0,n,2):
    alice_sum+=a[i]
  for k in range(1,n,2):
    bob_sum+=a[k]
    
print(alice_sum-bob_sum)

Solution (Python):
N=int(input())
a=[int(x) for x in input().split()]
Alice=0
Bob=0
for i in range(N):
  if i%2==0:
    Alice=Alice+max(a)
    a.remove(max(a))
  else:
    Bob=Bob+max(a)
    a.remove(max(a))
print(Alice-Bob)

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

Solution (Python):
n, a = int(input()), 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)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse = True)
Sabun = 0
for i in range(len(A)):
    if i % 2 == 0:
        Sabun += A[i]
    elif i % 2 == 1:
        Sabun -= A[i]
print(Sabun)

Solution (Python):
N = int(input())
a = list(map(int, input().split(' ')))

aSorted = sorted(a, reverse=True)

alice = 0
bob = 0

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

print(alice - bob)

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

Solution (Python):
n = int(input())
a = sorted(list(map(int,input().split())),reverse=True)
alice = 0
bob = 0

while True:
  alice += a[0]
  del a[0]
  if a == []:
    break
  bob += a[0]
  del a[0]
  if a == []:
    break

print(alice - bob)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
aa=sorted(a)
ans1=0
ans2=0
for i in range(n):
  if i%2==0:
    ans1+=aa[i]
  else:
    ans2+=aa[i]
print([ans2-ans1,ans1-ans2][n%2])

Solution (Python):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    alice, bob = 0, 0
    a = sorted(a)
    for i, x in enumerate(a[::-1]):
        if i % 2 == 0:
            alice += x
        else:
            bob += x
    print(alice - bob)


if __name__ == "__main__":
    main()

Solution (Python):
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)

Solution (Python):
n=int(input())
card=list(map(int,input().split()))
card.sort(reverse=True)
for i in range(1,n,2):
    card[i]*=(-1)
print(sum(card))

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

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

a.sort(reverse=True)

cnt = 0
Alice = 0
Bob = 0
while cnt < n:
    cnt += 1
    if cnt % 2 != 0:
        Alice += a[cnt-1]
    else:
        Bob += a[cnt-1]

print(Alice - Bob)

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

Solution (Python):
N = int(input())
numlist=list(map(int,input().split()))
sortnumlist=sorted(numlist,reverse=True)



alice_total = 0
bob_total = 0
for x,y in enumerate (sortnumlist):
    if x %2 ==0:
        alice_total = alice_total + y
    elif x %2 ==1:
        bob_total = bob_total + y
        



answer = alice_total  - bob_total
print(answer)

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

ans = 0
k = 0
for i in range(n):
  res = max(a)
  if k % 2 == 0:
    ans += res
  else:
    ans -= res
  a.remove(res)
  k += 1
  
print(ans)

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

Solution (Python):
N = int(input())
S = list(map(int, input().split()))

S.sort(reverse=True)
if N%2 == 0:
    ans = 0
else:
    ans = S[-1]
for i in range(N//2):
    ans += S[2*i]-S[2*i+1]
print(ans)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a=sorted(a, reverse=True)
scorea=0
scoreb=0
for i in range(n):
    if i%2==0:
        scorea+=a[i]
    else:
        scoreb+=a[i]

print(scorea-scoreb)

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

Solution (Python):
N = input().split()
a = list(map(int,input().split()))
a.sort(reverse=True)
Bob = 0
Alice = 0
for i,b in enumerate(a):
    if i % 2 == 0:
        Alice += b
    else:
        Bob += b

print(Alice - Bob)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

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

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

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

Solution (Python):
n = int(input())
al = list(map(int, input().split()))

als = sorted(al,reverse = True)

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

print(alice-bob)

Solution (Python):
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)

Solution (Python):

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

a.sort()
a = a[::-1]

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

print(a_total-b_total)

Solution (Python):
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)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
alice = sum(a[::2])
bob = sum(a[1::2])

print(alice-bob)

Solution (Python):

N = int(input())


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




Alice = 0
Bob = 0


x = 0


while not(len(a) == 0):
    if x%2 == 0:
        Alice += a.pop(0)

        
        x += 1
        

    else:
        Bob += a.pop(0)
        
        x += 1

print(Alice - Bob)

Solution (Python):

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

sum_A = 0
sum_B = 0

t = 0
while not(max(Cards) == 0):
        if t % 2 == 0:
            sum_A += max(Cards)
            a = Cards.index(max(Cards))
            Cards[a] = 0
            t += 1
        else:
            sum_B += max(Cards)
            a = Cards.index(max(Cards))
            Cards[a] = 0
            t += 1

print(sum_A - sum_B)

Solution (Python):
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.pop(0)
  else:
    Bob += a.pop(0)

print(Alice - Bob)

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

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

Solution (Python):
n = int(input())
a = sorted(list(map(int,input().split())),reverse=True)
alice = 0
bob = 0

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

print(alice - bob)

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

Alice = 0
Bob = 0


ld = sorted(a, reverse=True)

Alice = ld[:: 2]


Bob = ld[1:: 2]


Alice_a = sum(Alice)
Bob_a = sum(Bob)


print(Alice_a - Bob_a)

Solution (Python):
N = int(input())
list_a = list(map(int, input().split()))
list_a.sort(reverse=True)
Alice = sum(list_a[::2])
Bob = sum(list_a[1::2])
print(Alice-Bob)

Solution (Python):
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)

Solution (Python):
import sys
input = sys.stdin.readline

N = int(input())
A = [int(x) for x in input().split()]

A.sort(reverse=True)
alip = sum(A[i] for i in range(len(A)) if i % 2 == 0)
bobp = sum(A[i] for i in range(len(A)) if i % 2 == 1)
diff = alip - bobp
print(diff)