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

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

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

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

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

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

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


print(alice-bob)

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

Alice = 0
Bob = 0
while len(cards) >= 2:
    Alice += cards[-1]
    cards = cards[:-1]
    Bob += cards[-1]
    cards = cards[:-1]
if len(cards) == 1:
    Alice += cards[-1]
print(Alice - Bob)

Solution (Python):


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

for i in lis[::2]:
    a += i

for i in lis[1::2]:
    b += i

print(a - b)

Solution (Python):


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

for i in lis[::2]:
    a += i

for i in lis[1::2]:
    b += 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):
def abc088b_card_game_for_two():
    n = int(input())
    a = sorted(list(map(int, input().split())))
    alice = bob = 0
    for i in range(len(a)):
        if i % 2 == 0:
            alice += a.pop()
        else:
            bob += a.pop()
    print(alice - bob)
abc088b_card_game_for_two()

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

Solution (Python):
import math
N = int(input())
alst = list(map(int, input().split()))
list.sort(alst, reverse = True)
answer = 0
for i in range(N):
    answer += alst[i] * math.pow(-1, i)
print(int(answer))

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

Solution (Python):
N = input()
A = list(input().split())
A = list(map(int,A))
A = sorted(A,reverse = True)
a = 0
b = 0
try :
  while len(A) != 0 :
    a += A.pop(0)
    b += A.pop(0)
  print(a-b)
except IndexError :
  print(a-b)

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

print(abs(a-b))

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

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

alice = 0
bob = 0

for i in range(int(N/2) + 1):
	if len(cards) > 0:
		alice += max(cards)
		cards.remove(max(cards))
	if len(cards) > 0:
		bob += max(cards)
		cards.remove(max(cards))
	
print(alice - bob)

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

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

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

A=[]
B=[]

for i in range(len(a)):
    if i%2==1:
        A.append(a[i])
    else:
        B.append(a[i])

print(abs(sum(A)-sum(B)))

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

Solution (Python):
"""Boot-camp-for-Beginners_Easy010_B_Toll-Gates_29-August-2020.py"""
import numpy as np

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

Alice = [a[i] for i in range(0, len(a), 2)]
Bob = [a[i] for i in range(1, len(a), 2)]



s_max = 0
for i in range(len(Alice)):
    s_max += Alice[i]
s_min = 0
for i in range(len(Bob)):
    s_min += Bob[i]


print(s_max-s_min)

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

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 = [int(s) for s in input().split()]

alice_total = 0
bob_total = 0

cards.sort(reverse=True)

for i in range(len(cards)):
  if i % 2 == 0:
    alice_total += cards[i]
  else:
    bob_total += cards[i]

diff = alice_total - bob_total
print(diff)

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

a = sorted(a, 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 = 0
B = 0
while True:
  m_a = max(a)
  A += m_a
  a.remove(m_a)
  if len(a) == 0: break
  
  m_b = max(a)
  B += m_b
  a.remove(m_b)
  if len(a) == 0: break

print(A-B)

Solution (Python):
loopCnt = int(input())
cards = list(map(int, input().split()))

alice = 0
bob = 0

cards.sort(reverse=True)

for i in range(loopCnt):
  if i == 0 or i%2 == 0:
    alice += cards[i]
  elif i%2 == 1:
    bob += cards[i]

print(alice-bob)

Solution (Python):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    score = [0, 0]
    sort_a = sorted(a, reverse=True)

    for i in range(n):
        if i >= 2:
            sub_i = i % 2
        else:
            sub_i = i
        score[sub_i] += sort_a[i]

    print(score[0] - score[1])


if __name__ == "__main__":
    main()

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

Solution (Python):

a=int(input())
b=list(map(int,input().split()))
b.sort()
total=0
total2=0
for i in range(a):
    if i%2==0:
        total+=b[i]
    else:
        total2+=b[i]
print(max(total,total2)-min(total,total2))

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

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

a.sort(reverse = True)

diff = 0
for i in range(N):
  diff += ((-1) ** i) * a[i]

print(diff)

Solution (Python):
n = int(input())
alst = list(map(int, input().split()))
alst.sort(reverse = True)
ans = 0
pm = 1
for a in alst:
    ans += a * pm
    pm *= -1
print(ans)

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

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

a.sort(reverse=True)

pt_alice = 0
pt_bob = 0
alices_turn = True
for i in range(N):
    if alices_turn:
        pt_alice += a[i]
    else:
        pt_bob += a[i]
    alices_turn = not alices_turn

print(pt_alice-pt_bob)

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

while(cards != []):
    result += max(cards)
    cards.remove(max(cards))
    if cards != []:
        result2 += max(cards)
        cards.remove(max(cards))

print(result-result2)

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

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

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


main()

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

Solution (Python):

N = int(input())
a = list(map(int, input().split()))
A = 0
B = 0
aa = sorted(a)
for i in range(0, N, 2):
    A += aa[-i-1]
    if (i+2)<=N:
        B += aa[-i-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):
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007



def main():
	n = int(input())
	
	
	al=lin()
	al.sort(reverse=True)
	return sum(al)-(2*sum(al[1::2]))
	
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

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

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

alice =[]
bob = []

for i in range(len(a)):
    if i%2==0:
        alice.append(a[i])
    elif i%2 != 0:
        bob.append(a[i])
dif = sum(alice) - sum(bob)
print(dif)

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

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

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

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

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort()
al = 0
bo = 0
while a:
    al += a.pop(-1)
    if not a:
        break
    bo += a.pop(-1)
print(al-bo)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
b = len(a)
a_sum = 0
b_sum = 0
for i in range(b):
    if i % 2 == 0:
        a_sum = a_sum + a.pop(0)
    else:
        b_sum = b_sum + a.pop(0)
print(a_sum-b_sum)

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

Solution (Python):
n=int(input())
a=sorted(list(map(int,input().split())),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=sorted(list(map(int,input().split())),reverse=True)
al=[a[2*i] for i in range(n//2)]
bo=[a[2*i+1] for i in range(n//2)]
if n%2!=0:
  al.append(a[-1])
print(sum(al)-sum(bo))

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort()
if n%2 == 0:
    alice = sum(a[1::2])
    bob = sum(a[::2])
else:
    alice = sum(a[::2])
    bob = sum(a[1::2])
print(alice-bob)

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

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

for i in range(len(l)):
    if i % 2 == 0:
        Alice += l[i]
    else:
        Bob += l[i]
print(Alice - 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()
a.reverse()
b=[]
if len(a)%2==0:
    for i in range(0,(len(a)//2)):
        b.append(a[2*i]-a[2*i+1])
else:
    for i in range(0,(len(a)//2)):
        b.append(a[2*i]-a[2*i+1])
    b.append(a[len(a)-1])
print(sum(b))

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

alice=0
bob=0

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

Solution (Python):
N = int(input())
A = sorted(map(int, input().split()),reverse=True)
print( sum(A[0::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=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
sumA=0; sumB=0;
for i in range(N) :
  if i%2==0 :
    sumA+=a[i]
  else :
    sumB+=a[i]
print(sumA-sumB)

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

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

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

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

Solution (Python):
N = int(input())
A = sorted(list(map(int, input().split())))
print(sum(A[-1::-2])-sum(A[-2::-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):
  temp = A.pop(0)
  if i % 2 == 0:
    Alice += temp
  else:
    Bob += temp

print(str(Alice - Bob))

Solution (Python):
def resolve():
    n = int(input())
    al = list(map(int, input().split()))
    al = sorted(al, reverse=True)
    an = 0
    bn = 0
    for i in range(n):
        if i % 2 == 0:
            an += al[i]
        elif i % 2 == 1:
            bn += al[i]
    print(an - bn)
resolve()

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

a_sorted = sorted(a, reverse=True)
alice = 0
bob = 0
for i in range(n):
    if i % 2 == 1:
        alice += a_sorted[i]
    else:
        bob += a_sorted[i]
print(abs(alice-bob))

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

nums.sort()
while nums:
    alice+=nums.pop()
    if nums:
        bob+=nums.pop()

print(alice-bob)

Solution (Python):
import math
import numpy as np
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
alice=0
bob=0
k=math.floor(n/2)
if (n%2)==0:
    for i in np.arange(1,k+1):
        alice+=a[2*i-2]
        bob+=a[2*i-1]
if (n%2)==1:
    for i in np.arange(1,k+1):
        alice+=a[2*i-2]
        bob+=a[2*i-1]
    alice+=a[n-1]  
print(alice-bob)

Solution (Python):
a=int(input())
b=[int(i) for  i in input().split()]
c=sorted(b,reverse=True)
x=0
y=0
for j in range(len(c)):
  if j%2==0:
    x+=c[j]
  else:
    y+=c[j]
print(x-y)

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

Solution (Python):
n = int(input())
arr = list(map(int, input().split()))
arr.sort()
alice = 0
bob = 0
for i in range(len(arr)):
    if i%2 == 0:
        alice += arr[i]
    else:
        bob += arr[i]
print(abs(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()
Alice = 0
Bob = 0
for i in range(N):
    if i % 2 == 0:
        Alice += a.pop()
    else:
        Bob += a.pop()
print(Alice - Bob)

Solution (Python):
n=int(input())
a=sorted([int(i)for i in input().split()])
res=0
for i in range(n):
    tmp=a.pop(-1)
    if i%2==0:
        res+=tmp
    else:
        res-=tmp
print(res)

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

target_num = sum(a_list[::2]) - sum(a_list[1::2])
print(target_num)

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


a_list = sorted(a_list, reverse=True)


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

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

A, B = 0, 0

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

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

Solution (Python):
n = int(input())
a = [int(an) for an in input().split()]
ans = a[0]
if n > 1:
  a.sort(reverse=True)
  ans = sum(a[::2]) - sum(a[1::2])
print(ans)

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

a_list.sort(reverse = True)
alice_sum = 0
bob_sum = 0
for i in range(len(a_list)):
    if i % 2 == 0:
        alice_sum += a_list[i]
    else:
        bob_sum += a_list[i]

print(alice_sum - bob_sum)

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

a.sort(reverse=True)
ansa,ansb=0,0
for i in range(N):
    if i%2==0:
        ansa+=a[i]
    else:
        ansb+=a[i]
print(ansa-ansb)

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

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

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

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

Solution (Python):



def main():
    N = int(input())
    aList = list(map(lambda x: int(x), input().split()))

    aliceValue = 0
    bobValue = 0
    isAliceTurn = True
    while len(aList) > 0:
        maxValue = max(aList)
        aList.remove(maxValue)
        if isAliceTurn:
            aliceValue += maxValue
        else:
            bobValue += maxValue

        isAliceTurn = not isAliceTurn

    print(aliceValue - bobValue)


if __name__ == "__main__":
    main()

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

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
Alice = 0
Bob = 0
isAlice = True
for i in range(n):
    tmp = max(a)
    a.remove(tmp)
    if isAlice:
        Alice += tmp
    else:
        Bob += tmp
    isAlice = not(isAlice)
print(Alice-Bob)

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

sorted_a = sorted(a, reverse=True)

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

print(alice-bob)

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

alice = 0
bob = 0

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

print(alice - bob)

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

Solution (Python):
N = int(input())
A = sorted(list(map(int,input().split())), reverse = True)
a = 0 
b = 0
for i in range(len(A)):
    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()))
b = sorted(a, reverse=True)

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

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

b = sorted(a, reverse=True)

ans_Alice = 0
ans_Bob = 0

for i in range(x): 
    if i%2 ==0:
        ans_Alice += int(b[i])
    else:
        ans_Bob += int(b[i])

        
print(int(ans_Alice) - int(ans_Bob))

Solution (Python):
N = int(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):
input();a,b,c=0,0,sorted(map(int,input().split()))
while c:
  a+=c.pop()
  b+=c.pop() if c else 0
print(a-b)

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

alice = []
bob = []
for i in range(N):
    if i % 2 == 0:
        alice.append(a[i])
    else:
        bob.append(a[i])

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

Solution (Python):
N = int(input())
A = [int(n) for n in 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=0
bob=0
for i in range(n):
  if i%2==0:
    alice+=a[i]
  else:
    bob+=a[i]
print(alice-bob)

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

	a.sort(reverse = True)

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

	print(Alice - Bob)

  
if __name__ == "__main__":
  	main()

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

Solution (Python):

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

a_list = sorted(a_list, reverse = True)



Alice_Score = 0
Bob_Score = 0

for i in range(n):

    
    if i % 2 == 0 :
        Alice_Score = Alice_Score + a_list[i]
    else :
        Bob_Score = Bob_Score + a_list[i]

ans = Alice_Score - Bob_Score

print(ans)

Solution (Python):
N = int(input())
if N == 1:
    a = int(input())
    print(a)
else:
    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):
num = int(input())
org_list = list(map(int, input().split()))

new_list = sorted(org_list, reverse=True)

alice_sum = sum(new_list[::2])
bob_sub = sum(new_list[1::2])



print(str(alice_sum-bob_sub))

Solution (Python):
import sys
n,*a=map(int,sys.stdin.read().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
for i in range(0,N,2):
    alice += a[i]
bob = 0
for i in range(1,N,2):
    bob += a[i]
print(alice - bob)

Solution (Python):
from collections import deque

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

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

Solution (Python):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
li = sorted(rl(), reverse=True)
a = 0
b = 0
for i in range(n):
  if i & 1 == 0:
    a += li[i]
  else:
    b += li[i]
print(a-b)

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

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

while l:
  m1 = max(l)
  a += m1
  l.remove(m1)
  if l:
    m2 = max(l)
    l.remove(m2)
print( 2 * a - s )

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

if n%2 != 0:
  a.append(0)
  n += 1
 
a.sort()
d = 0

for i in range(int(n/2)):
               d += a[2*i+1]-a[2*i]
           
print(d)

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

Solution (Python):
n = int(input())
arr = list(map(int, input().split()))
alice = 0
bob = 0
chance = "A"
for _ in range(len(arr)):
	i = max(arr)
	if chance == "A":
		alice += i
		chance = "B"
	else:
		bob += i
		chance = "A"
	indx = arr.index(i)
	del arr[indx]
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)

ali = 0
bob = 0

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

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

Solution (Python):
N = int(input())
data = list(map(int, input().split()))
Alice = 0
Bob = 0
count = 0
while N > count:
  high = data[0]
  point = 0
  for i in range(N):
    if data[i] > high:
      high = data[i]
      point = i
  if count % 2 == 0:
    Alice += high
  else:
    Bob += high
  data[point] = 0
  count += 1
print(Alice - Bob)

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

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

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

Solution (Python):
n=int(input())
a=[int(i)for i in input().split()]
a.sort()
alice=0
bob=0
for i in range(n):
    if i%2==0:
        alice+=a.pop(-1)
    else:
        bob+=a.pop(-1)
print(alice-bob)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
Ali,Bob=0,0
for i in range(n):
    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)
a.append(0)
Ali,Bob=0,0
for i in range(0,n,2):
    Ali +=a[i]
    Bob +=a[i+1]
print(Ali-Bob)

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

alice = 0
bob = 0

a.sort()
a.reverse()

for i in a[::2]:
    alice += i

for j in a[1::2]:
    bob += j

print(alice-bob)

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

ali = 0
bob = 0

a.sort()

while True:
    if(len(a) > 0):
        ali += a.pop()
    else:
        break
    if(len(a) > 0):
        bob += a.pop()
    else:
        break

print(ali - bob)

Solution (Python):
N=int(input())
A=[]
A_before=input().split(' ')
for i in range(len(A_before)):
  A.append(int(A_before[i]))
for i in range(len(A)):
  for j in range(len(A)-1):
    if A[j]<A[j+1]:
      x=A[j]
      A[j]=A[j+1]
      A[j+1]=x
a=0
b=0
for i in range(len(A)):
  if i%2==0:
    a=a+A[i]
  else:
    b=b+A[i]
print(a-b)

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

A = sorted(A)[::-1]

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