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

alice_sum = 0
bob_sum = 0

while len(an_list) != 0:
    alice_sum += max(an_list)
    an_list.remove(max(an_list))
    if len(an_list) != 0:
        bob_sum += max(an_list)
        an_list.remove(max(an_list))

print(alice_sum - bob_sum)

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

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

sum_alice = 0
sum_bob = 0
a = sorted(a, reverse=True)

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

print(sum_alice - sum_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())
list= list(map(int, input().split()))
alice=[]
bob=[]
list.sort(reverse=True)
for i in range(N):
    if i%2==0:
        alice.append(list[i])
    else:
        bob.append(list[i])
print(sum(alice)-sum(bob))

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



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

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

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

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

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
A.sort(reverse=True)
L = 0

for i in range(len(A)):
     L += ((-1)**i)*A[i]

print(L)

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

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

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

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

sort_a_list = sorted(a_list, reverse=True)

alice = 0
bob = 0

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

print(alice - bob)

Solution (Python):
import math





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

alice = 0
bob   = 0

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

Solution (Python):
import math





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

alice = 0
bob   = 0

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

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

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

Solution (Python):
import numpy as np

def solve(n, A):
    res = 0
    while A:
        i = np.argmax(A)
        res += A[i] if (len(A) + n) % 2 == 0 else -A[i]
        A.pop(i)
    return res

_n = int(input())
_A = list(map(int, input().split()))
print(solve(_n, _A))

Solution (Python):
N = int(input())
a = sorted([int(x) for x in input().split()], reverse=True)

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

Solution (Python):
N = int(input())
a = sorted([int(x) for x in input().split()], reverse=True)

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

Solution (Python):
"""
author : halo2halo
date : 24, Jan, 2020
"""

import sys




read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

A = int(readline())
S = [int(i) for i in readline().decode().split()]
S.sort()
S.reverse()

ans = 0
j = 1
for i in S:
    ans += i * j
    j *= -1
print(ans)

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

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
x = []
y = []
for i, v in enumerate(sorted(a, reverse=True)):
    if (i + 1) % 2 != 0:
        x.append(v)
    else:
        y.append(v)
print(sum(x) - sum(y))

Solution (Python):
n=input()

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

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

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

Solution (Python):


def main():
  n = int(input())
  a = list(map(int, input().strip().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)
    
    

if __name__=="__main__":
  main()

Solution (Python):



def input_one_number():
    return int(input())


def input_multiple_number():
    return map(int, input().split())


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


def input_map():
    return [list(map(int,list(input()))) for i in range(h)]


def print_list(list):
    print(*list)
    return


def print_map(maplist):
    for i in maplist:print(*i, sep='')
    return


def generate_primenums():
    n = 100
    primes = set(range(2, n+1))
    for i in range(2, int(n**0.5+1)):
        primes.difference_update(range(i*2, n+1, i))
    primes=list(primes)
    return primes

def memo():
    a=[0]*5
    b=a  
    b2=a[:]  
    a[1]=3
    print('b:{}, b2:{}'.format(b,b2))  
    
    import copy
    a= [[0]*3 for i in range(5)] 
    b=copy.deepcopy(a)  
    
    
    odd=[i for i in range(100) if i%2==1] 

    
    import bisect
    a = [1, 2, 3, 5, 6, 7, 8, 9]
    b=bisect.bisect_left(a, 8)

    
    from itertools import permutations, combinations,combinations_with_replacement,product
    a=['a','b','C']
    print(list(permutations(a)))
    print(list(combinations(a,2)))
    print(list(combinations_with_replacement(a,3)))



def kaijo(n):
    import math
    return math.factorial(n)


def num_combination(n,r):
    import math
    return math.factorial(n) // math.factorial(n - r)



def calc_gcd(a,b):
    import fractions
    GCD=fractions.gcd(a,b)
    lcm=a*b//gcd
    return gcd,lcm


def calc_gcd_list(l):
    gcd = l[0]
    for i in range(1, N):
        gcd = fractions.gcd(gcd, l[i])
    return gcd


def sum_digit(n):
    sum = 0
    while n > 0:
        sum += n%10
        n //= 10
    return sum

N = input_one_number()
lst_a = input_multiple_number_as_list()

lst_a.sort(reverse=True)

alice = 0
bob = 0

if len(lst_a) %2 == 1:
    lst_a.append(0)

for i in range(len(lst_a)//2):
    alice += lst_a[i*2]
    bob += lst_a[i*2+1]

print(alice-bob)

Solution (Python):
def getInput():
    return [int(i) for i in input().rstrip().split(' ')]

N = getInput()[0];
a_i = getInput()
a_i.sort(reverse=True)
ret = 0

for i in range(1, N+1):
    if not i % 2 == 0:
        ret += a_i.pop(0)
    else:
        ret -= a_i.pop(0)
print(ret)

Solution (Python):
def getInput():
    return [int(i) for i in input().rstrip().split(' ')]

N = getInput()[0];
a_i = getInput()
ret = 0

for i in range(1, N+1):
    if not i % 2 == 0:
        ret += a_i.pop(a_i.index(max(a_i)))
    else:
        ret -= a_i.pop(a_i.index(max(a_i)))
print(ret)

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):
import math
N = int(input())
a = list(map(int, input().split()))
a.sort(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())
lst = list(map(int, input().split()))
lst.sort(reverse = True)
A = 0
B = 0


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

print(A - B)

Solution (Python):
import numpy as np

n = int(input())
n = np.array(list(map(int, input().split())))
n_sort = np.sort(n)[::-1]
alice=0
bob=0




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



print(alice - bob)

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

a.sort(reverse=True)
alice_score = sum(a[0::2])
bob_score = sum(a[1::2])

print(alice_score - bob_score)

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

Solution (Python):

import numpy as np
N = int(input())

line = list(map(int, input().split()))
a = b = 0

for i in range(N):
    n = max(line)
    line.remove(n)
    if i % 2:
        b += n
    else:
        a += n
        
print(a-b)

Solution (Python):
n = int(input())
cardList = map(int,input().split())
cl = list(cardList)
cl.sort(reverse=True)
alice = 0
bob = 0
turn = True
for c in cl:  
  if turn:
    alice+= c
    turn = False
  else:
    bob +=c
    turn =True
    
print(alice-bob)

Solution (Python):

def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    a.sort(reverse=True)
    print(sum([a[i] for i in range(n) if i%2 == 0]) - sum([a[i] for i in range(n) if i%2 !=0]))
main()

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=sum(a[0::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

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 = sorted(a, reverse=True)

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


if alice > bob:
    print(alice - bob)
else:
    print(bob-alice)

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

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

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

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a = sorted(a)[::-1]
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
a = sorted(a, key= lambda x: -x)

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 = [int(i) for i in input().split()]
a.sort(reverse=True)
print(sum(a[0::2]) - sum(a[1::2]))

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

Solution (Python):
N = int(input())
A = [ int(a) for a in input().split() ] 
A_sort = sorted(A) 
A_sort.sort(reverse=True) 
sum_alice = 0
sum_bob = 0
for i in range(0,N):
  if i%2 == 0:
    sum_alice += A_sort[i]
  else:
    sum_bob += A_sort[i]
print(sum_alice - sum_bob)

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

alice = []
bob = []

for i in range(1, n+1):
    if i%2!=0:
        alice.append(a.pop(a.index(max(a))))
    else:
        bob.append(a.pop(a.index(max(a))))

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

Solution (Python):

"""AtCoder Beginner Contest 088: B - Card Game for Two
https://atcoder.jp/contests/abc086/tasks/abc088_b
"""

__author__ = 'bugttle <bugttle@gmail.com>'


def main():
    N = int(input())
    an = list(map(int, input().split()))

    answer = 0
    an.sort(reverse=True)
    for i in range(N):
        if i % 2 == 0:
            answer += an[i]
        else:
            answer -= an[i]

    print(answer)


if __name__ == '__main__':
    main()

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

a_s = sorted(al, reverse=True)

ali = 0
bob = 0
count = 0

for a in a_s:
    count += 1
    if count %2 != 0:
        ali += a
    else:
        bob += a

print(ali-bob)

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort()
ab = [x for x in a[1::2]]
ba = [x for x in a[0::2]]
print(abs(sum(ab)-sum(ba)))

Solution (Python):
n = int(input())
ais = input().split()
ais_int = [int(a) for a in ais]
ais_sort = ais_int.sort()
alice = 0
bob = 0
if n % 2 == 0:
  for i in range(n):
    if i % 2 == 1:
      alice += int(ais_int[i])
    else:
      bob += int(ais_int[i])
else:
  for j in range(n):
    if j % 2 == 0:
      alice += int(ais_int[j])
    else:
      bob += int(ais_int[j])
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())
lista = list(map(int, input().split()))

point = 0

lista.sort()

for _ in range((n + 1) // 2):
  point += lista.pop()
  if lista == []:
    break
  else:
    point -= lista.pop()
    
print(point)

Solution (Python):
N = int(input())
a = [int(x) for x in input().split()]
a = sorted(a, reverse=True)
ans = 0
for n in range(0,N,2):
    ans += a[n]
    if n+1 < N:
        ans -= a[n+1]
print(ans)

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]

diff = Alice - Bob
print(diff)

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


import numpy as np

input()

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

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

Solution (Python):
import sys

if __name__ == "__main__":
    args = sys.stdin.read().split()
    N, A = int(args[0]), list(map(int, args[1:]))  
    A.sort(reverse=True)

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

Solution (Python):
n = int(input())
l = [int(i) for i in input().split()]

nl = sorted(l, reverse=True)

a = 0
b = 0

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

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

Solution (Python):

n = int(input())
a = [int(i) for i in input().split()]

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

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

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

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

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

Solution (Python):
N = int(input())
scores = list(int(i) for i in input().split())

sorted_scores = sorted(scores)[::-1]
alice = sum(sorted_scores[::2])
bob = sum(sorted_scores[1::2])

print(alice - bob)

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

sorted_a = sorted(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]

print(alice-bob)

Solution (Python):
N = int(input())
points = sorted([int(i) for i in input().split()])[::-1]

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

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


Alice = []
Bob = []
for i in range((N + 1) // 2):
  
  max_val = max(aN)
  Alice.append(max_val)
  aN.remove(max_val)
  if len(aN) > 0:
    
    max_val = max(aN)
    Bob.append(max_val)
    aN.remove(max_val)

print(sum(Alice) - sum(Bob))

Solution (Python):
N = int(input())
n = map(int, input().split())
an = sorted(n, reverse=True)
i = 0
A = 0
B = 0
while i != N:
  A += an[i]
  i += 1
  if i != N:
    B += an[i]
    i += 1
print(A - B)

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

Solution (Python):
N = int(input())
a = sorted(map(int, input().split()), reverse=True)
alice = a[0::2]
bob = a[1::2]

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

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

    alice, bob = 0,0

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

    print(alice-bob)

if __name__ == '__main__':
    main()

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

alice=0
bob=0

for i in range(n):
    if i%2==0:
        alice+=newL[i]
    elif i%2==1:
        bob+=newL[i]
print(alice-bob)

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

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

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

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())
cards = list(map(int, input().split()))
a = 0
b = 0

cards.sort(reverse=True)

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

print(a - b)

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

cards.sort(reverse=True)

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

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

alice = []
a.sort(reverse=True)
for i in range(0, N, 2):
    alice.append(a[i])
print(2 * sum(alice) - sum(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())
a = list(map(int,input().split()))
l = sorted(a, reverse=True)

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

print(ans)

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


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


A=0
B=0

for i in range(N):
    if i%2==0:
        A+=max(card_list)
        card_list.remove(max(card_list))
        
    else:
        B+=max(card_list)
        card_list.remove(max(card_list))
        




print(A-B)

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

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

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

Alice = 0
Bob = 0
A.sort(reverse=True)
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()))

Alice = 0
Bob = 0
A.sort(reverse=True)
for i in range(len(A)):
    if i%2 == 0:
        Alice += A[0]
    else:
        Bob += A[0]
    A.pop(0)
    
print(Alice-Bob)

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

Alice = 0
Bob = 0
for i in range(len(A)):
    m = max(A)
    if i%2 == 0:
        Alice += m
    else:
        Bob += m
    A.remove(m)
    
print(Alice-Bob)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
alice, bob = 0, 0
while(True):
    alice += max(A)
    A.remove(max(A))
    if not A: break
    bob += max(A)
    A.remove(max(A))
    if not A: break
print(alice - bob)

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

List.sort(reverse=True)

ans = sum(List[::2])-sum(List[1::2])

print(ans)

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

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

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

card_list_ex = sorted(card_list, reverse=True)


alice,bob = 0,0
for i,j in enumerate(card_list_ex):
    if i % 2 == 0:
        alice += j
    else:
        bob += j
res = alice - bob
print(res)

Solution (Python):

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

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

print(alice - bob)

Solution (Python):

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

alice = 0
bob = 0
for i in range(n):
    if len(cards) == 0:
        break
    card = max(cards)
    cards.remove(card)
    if i % 2 == 0:
        alice += card
    else:
        bob += card

print(alice - bob)

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 = sum(A[::2])
bob = sum(A[1::2])

print(alice - bob)

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

A = 0
B = 0

n = round(N/2+0.1)

while True:
  try:
    A = A + max(a)
    a.pop(a.index(max(a)))
    B = B + max(a)
    a.pop(a.index(max(a)))
  except:
    break

print(A-B)

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

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

print(Alice-Bob)

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

Alice = []
Bob = []
for i in range(n):
    if i % 2 == 0: 
        Alice.append(max(a))
    else:
        Bob.append(max(a))
    a.remove(max(a))

print(sum(Alice)-sum(Bob))

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

Solution (Python):


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

_as.sort(reverse=True)

Alice = _as[0::2]
Bob = _as[1::2]

print(sum(Alice) - sum(Bob))

Solution (Python):
N = int(input())
a = [int(x) for x in input().split()]
a_order = sorted(a, reverse=True)
alice, bob = 0, 0

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

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

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

Solution (Python):

N = input()

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

list.sort(li,reverse=True)



l = 0
g = 0

for i in range(0,(len(li)),2):
    
    l += li[i]



for j in range(1,(len(li)),2):
    
    g += li[j]


print(l-g)

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

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
Alice = 0
A.sort(reverse=True)
for i in range(0,N,2):
  Alice += A[i]
print(2*Alice - sum(A))

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

total_a = 0
total_b = 0

a.sort(reverse=True)
for i in range((n+1)//2):
    total_a += a[i*2]
for i in range(n//2):
    total_b += a[i*2 + 1]
print(total_a - total_b)

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

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

Solution (Python):


N = int(input())
a = [int(x) for x in input().split()]
a.sort(reverse = True)

alice_point = 0
bob_point = 0
for index in range(N):
	if index % 2 == 0:
		alice_point += a[index]
	else:
		bob_point += a[index]

print(alice_point - bob_point)

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

numArraySorted = sorted(numArray,reverse=True) 

alice = 0
bob = 0

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

print(alice-bob)

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

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

Card_n.sort()

A_n = []
B_n = []

for i in range(len(Card_n)):
    if not i%2 == 0:
        A_n.append(Card_n.pop())
    else:
        B_n.append(Card_n.pop())



print(abs(sum(A_n) - sum(B_n)))

Solution (Python):
import sys


def solve(inp):
    N = int(inp.readline())
    A = list(reversed(sorted(map(int, inp.readline().split(' ')))))

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

    return str(a - b)


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    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):
import sys
input = sys.stdin.readline
N = int(input())
a = [int(x) for x in input().split()]
a = sorted(a, reverse=True)
A = sum(a[:N:2])
B = sum(a[1:N:2])
print(A - B)

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

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

As.sort(reverse=True)
Alice = sum(As[::2])
Bob = sum(As[1::2])
print(Alice-Bob)

Solution (Python):
input()

As = sorted([int(a) for a in input().split()], reverse=True)
alice = sum([a if i % 2 == 0 else 0 for i, a in enumerate(As)])

print(alice - (sum(As) - alice))

Solution (Python):
temp=input()
temp=input()
A=[int(x) for x in temp.split()]
A.sort(reverse=True)

sum=0
for x in range(len(A)):
  sum=sum+(-1)**(x)*A[x]
print(sum)

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

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

Solution (Python):


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

a = sorted(a, reverse = True)



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



bob = sum(a) - alice

print(alice - bob)

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

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

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

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

sum1 = 0
sum2 = 0

for i in range(len(A)):
    if i%2==0:
        sum1 = sum1 + A[i]
    else:
        sum2 = sum2 + A[i]
print(sum1-sum2)

Solution (Python):

 
import math
import itertools
import sys
import copy
 



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

if len(a)%2 != 0 :
  a.append(0)
a.sort(reverse=True)

sum = 0
for i in range(0, len(a), 2) :
  sum += (a[i]-a[i+1])
print (sum)

Solution (Python):



class Player:

    def __init__(self):
        self.point = 0

    def add_point(self, point):
        self.point += point

    def get_point(self):
        return self.point


def main():

    _ = int(input())
    cards = list(map(int, input().split(' ')))
    cards = sorted(cards, reverse=True)

    alice = Player()
    bob = Player()
    players = [alice, bob]
    for i, card in enumerate(cards):
        players[i % len(players)].add_point(card)

    print(alice.get_point() - bob.get_point())

    return 0


if __name__ == '__main__':
    main()

Solution (Python):
sumajedan = 0
sumadva = 0

n = int(input())

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

a.sort(reverse = True)

for x in range(n):
    if x%2 == 0:
        sumajedan=sumajedan + a[x]
    else:
        sumadva = sumadva + a[x]
print(sumajedan - sumadva)