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):
if __name__=='__main__':
    N = int(input())
    a = list(map(int, input().split(' ')))
    a.sort()
    a = a[::-1]

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

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

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

print(alice-bob)

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

alice = 0
bob = 0
c = 0
while len(a) > 0:
    m = max(a)
    i = a.index(m)
    a.pop(i)
    if c % 2 == 0:
        alice += m
    else:
        bob += m
    c += 1

print(alice - bob)

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

A = 0
B = 0
i = 0
while len(a) > 0:
    if i % 2 == 0:
        A += a.pop()
    else:
        B += a.pop()
    i += 1
print(A - B)

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

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

for i in range(n):
    if(alice_flag):
        alice += max(a)
    else:
        bob += max(a)
    a[a.index(max(a))] = 0
    alice_flag = not(alice_flag)

print(alice-bob)

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

A.sort()
A.reverse()

Alice = sum(A[0::2])
Bob = sum(A[1::2])

print(Alice - Bob)

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

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

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

print(main())

Solution (Python):


n = int(input())
a = [int(s) for s in 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(reverse = 1)
al = 0
bo = 0
for i in range(N):
  if i%2==0:
    al += A[i]
  else:
    bo += A[i]
print(al-bo)

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

AS = sorted(A,reverse=True)
ans = 0
for i in range(len(AS)):
    if(i%2==0):
        ans += AS[i]
    else:
        ans -= AS[i]

print(ans)

Solution (Python):

import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))
p = [0, 0]
for i in range(n):
    p[i%2]  += a[np.argmax(a)]
    a[np.argmax(a)] = 0
print(p[0]-p[1])

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

    A.sort(reverse=True)
    alice = [A[i] for i in range(N) if not i & 1]
    bob = [A[i] for i in range(N) if i & 1]

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

main()

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

Solution (Python):
N=int(input())
ai=list(map(int,input().split()))
ai.sort()
ai.reverse()
al=0
bob=0
for i in range(0,N,2):
    al+=ai[i]
for i in range(1,N,2):
    bob+=ai[i]
print(al-bob)

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

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

Solution (Python):


from collections import deque
def document_it(func):
    def new_function(*args,**kwargs):
        print('Running function:', func.__name__)
        print('Positional arguments:', args)
        print('Kewword arguments:', kwargs)
        result = func(*args,**kwargs)
        print('Result:', result)
        return result
    return new_function


def exe():
    N = int(input())
    A = list(map(int,input().split()))
    A.sort()
    s = deque(A)
    alice =0
    bob = 0
    for i in range(N):
        if i % 2 == 0:
            alice += s.pop()
        else:
            bob += s.pop()
    print(alice-bob)

if __name__ == '__main__':
    exe()

Solution (Python):
N=int(input())
S=list(map(int, input().split()))
S.sort(reverse=True)
A=[]
B=[]
for i in range(N):
    if i%2==0:
        A.append(S[i])
    else:
        B.append(S[i])
print(sum(A)-sum(B))

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

Solution (Python):

"""
https://abc088.contest.atcoder.jp/tasks/abc088_b

"""
import sys
from sys import stdin
input = stdin.readline


def solve(cards):
    score_a = 0
    score_b = 0
    cards.sort(reverse=True)
    for i, c in enumerate(cards):
        if i % 2 == 0:
            score_a += c
        else:
            score_b += c
    return score_a - score_b


def main(args):
    N = int(input())
    cards = [int(x) for x in input().split()]
    ans = solve(cards)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):
n = input()
a = map(int, raw_input().split())
a.sort()
ct = 0

alice = 0
bob = 0
for i in reversed(a):
    if ct % 2 == 0:
        alice += i
    else:
        bob += i
    ct += 1

print alice - bob

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

a_s = sorted(a_s)

alice = 0
bob = 0
for i in range(N):
    if i % 2 == 0:
        alice += a_s.pop()
    else:
        bob += a_s.pop()

print(alice-bob)

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

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

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

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


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
c=0
d=0
a.sort()
e=len(a)-1
f=0
while(e>=0):
	if(f==0):
		c+=a[e]
		f=1
	elif(f==1):
		d+=a[e]
		f=0
	e-=1
print(c-d)

Solution (Python):
n=int(input())
a= [int(i) for i in input().split()]
a.sort(reverse=True)

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

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

a.sort(reverse=True)
a.append(0)

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

print(ans)

Solution (Python):
from sys import stdin
n = int(stdin.readline())
a = map(int,stdin.readline().split())
ans = 0
a.sort()
a.reverse()
for i in xrange(n):
 if i%2:
  ans -=a[i] 
 else:
  ans+=a[i]
print ans

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

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

    ans = alice - bob
    print(ans)


if __name__ == '__main__':
    main()

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

b.sort(reverse=True)
print(abs(sum(b[::2]) - sum(b[1::2])))

Solution (Python):
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
n=i1()
a=i2()
al=[]
bo=[]
a=sorted(a)
a=a[::-1]
for i in range(n):
 if i%2==0:
  al.append(a[i])
 else:
  bo.append(a[i])
print(sum(al)-sum(bo))

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

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

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
flag=0
A=0
B=0
for i in a:
  if flag==0:
    A+=i
    flag=1
  else:
    B+=i
    flag=0
print(A-B)

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

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

Solution (Python):



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

Solution (Python):
n = int(input())
a = [int(x) for x in input().split()]
a.sort(reverse=True)
s = sum(a)
sa = sum(a[::2])
print(2*sa-s)

Solution (Python):


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

alice = 0
bob = 0
flag = 0
while len(A):
    i = A.index(max(A))
    if flag == 0:
        alice += A[i]
        flag = 1
        del A[i]
    else:
        bob += A[i]
        flag = 0
        del A[i]

print(alice - bob)

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

n_a = 0
n_b = 0
for i, x in enumerate(A_LIST):
    if i % 2 == 0:
        n_a += x
    else:
        n_b += x
        
print(n_a - n_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=[int(i) for i in input().split()]
a.sort()
a.reverse()

s=0

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

print(s)

Solution (Python):
n = int(input())
a = [int(x) for x in input().split()]
a= sorted(a)
alice = sum(a[::2])
bob = sum(a[1::2])

print(abs(alice-bob))

Solution (Python):
N = int(input())
a = [int(i) for i in input().split()]
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)
print(sum(a[::2]) - sum(a[1::2]))

Solution (Python):

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

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

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

a.sort()
a.reverse()

ans1=0
ans2=0

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

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

Solution (Python):
n=int(raw_input())
N=(sorted(map(int,raw_input().split())))
N.reverse()
a=b=0
for i in range(n):
	if i%2==0:
		a+=N[i]
	else:
		b+=N[i]
print abs(a-b)

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

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

Solution (Python):
n = input()
a = map(int, raw_input().split())
a.sort(reverse=True)
s1 = 0
s2 = 0
for i, k in enumerate(a):
    if i % 2 == 0:
        s1 += k
    else:
        s2 += k
print s1 - s2

Solution (Python):
N = int(input())
a = [int(_) for _ in 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, 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())

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

a = b = 0
for i,v in enumerate(src):
    if i%2 == 0:
        a += v
    else:
        b += v
print(a - b)

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

Solution (Python):
n = int(input())
xs = list(sorted(list(map(int, input().split()))))[::-1]

ans = 0
s = 1
for x in xs:
  ans += s * x
  s *= -1
print(ans)

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

Solution (Python):
f = lambda :[int(i) for i in input().split()]

N = int(input())
a = f()

a.sort()
alice = 0
bob = 0
while a:
    alice += a.pop()
    if not(a):
        break
    bob += a.pop()
print(alice - bob)

Solution (Python):
import sys
import math
import collections
import itertools
import array
import inspect


sys.setrecursionlimit(10000)


def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))


def to_bin(x):
    return bin(x)[2:]


def dim2input(N):
    li = []
    for _ in range(N):
        li.append(list(map(int, input())))
    return li

""" input template
S = input()
N = int(input())
L = list(map(int, input().split()))
a, b = list(map(int, input().split()))
SL = list(input())
"""



dp = None

def main():
    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))

    print(Alice - Bob)

main()

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

Solution (Python):
N = input()
A = map(int, raw_input().split())
A.sort(key=lambda x:-x)

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

print a - b