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

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

Alice_score=0
Bob_score=0

isAliceTurn=True
for i in range(N):
    if(isAliceTurn):
        Alice_score+=cards.pop(0)
    else:
        Bob_score+=cards.pop(0)
    isAliceTurn = not isAliceTurn

print(Alice_score-Bob_score)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
count = 0
alice = 0
bob = 0
a.sort()
f = 0
while(len(a) != 0):
    if f == 0:
        alice = alice + a.pop(-1)
        f = 1
    else:
        bob = bob + a.pop(-1)
        f = 0
print(alice - bob)

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

a_list.sort()
a_list.reverse()

alice = 0
bob = 0
for i in range(0, len(a_list), 2):
    alice += a_list[i]

    if i + 1 < len(a_list):
        bob += a_list[i + 1]

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

turn = 0
point = [0,0]
while A:
    t = max(A)
    A.remove(t)
    point[turn%2] += t
    turn += 1

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

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

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

Solution (Python):
N = int(input())
cards = list(map(int, input().split()))
cards.sort()
alice = []
bob = []
for i in range(N):
    if i % 2 == 0:
        alice.append(cards.pop())
    else:
        bob.append(cards.pop())
print(sum(alice) - sum(bob))

Solution (Python):
N = int(input())
cards = list(map(int, input().split()))
alice = []
bob = []
for i in range(N):
    max_card = cards.pop(cards.index(max(cards)))
    if i % 2 == 0:
        alice.append(max_card)
    else:
        bob.append(max_card)
print(sum(alice) - sum(bob))

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):
if __name__ == '__main__':
    n = int(input())
    ai = list(map(int, input().split()))

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

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

a.sort()
alice = sum(a[0:N:2])
Bob = sum(a[1:N:2])

result = alice - Bob
result = abs(result)

print(result)

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

Solution (Python):
input()
s=[0,0]
t=0
for c in sorted(map(int,input().split()),reverse=True):
  s[t]+=c
  t=not t
print(s[0]-s[1])

Solution (Python):


N = int(input())
a_arr = [int(i) for i in input().split()]
a_arr2 = sorted(a_arr, reverse=True)
Alice = []
Bob = []

for j in range(len(a_arr2)):
  if j % 2 == 0:
    Alice.append(a_arr2[j])
  else:
    Bob.append(a_arr2[j])

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

Solution (Python):

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


sorted_a = sorted(a,reverse=True)

bob=0
alice=0

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

print(alice-bob)

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

a.sort()

suma, sumb = 0, 0
for i in range(n):
  if n % 2 != 0:
    if i % 2 == 0:
      suma += a[i]
    elif i % 2 != 0:
      sumb += a[i]
  elif n % 2 == 0:
    if i % 2 == 0:
      sumb += a[i]
    elif i % 2 != 0:
      suma += a[i]
      
print(suma - sumb)

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

data = map(int,raw_input().split())

data.sort(reverse=True)

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

print ans

Solution (Python):
import numpy as np
n = int(input())
cards = list(map(int,input().split()))

cards.sort(reverse=True)

sum = 0
sum += np.sum(cards[0::2])
sum -= np.sum(cards[1::2])
print(sum)

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


Alice = sum(cards[::2])
Bob = sum(cards[1::2])
print(Alice-Bob)

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

alice = sum([s for idx,s in enumerate(a) if idx%2==0])
bob   = sum([s for idx,s in enumerate(a) if idx%2==1])

print(alice-bob)

Solution (Python):

def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
def db(x): 
    global debug
    if debug: print(x)
debug = False
N = getInt()
a = getIntList()
a.sort()
a.reverse()
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())
card = list(map(int, input().split()))
card.sort(reverse = True)

A = 0
B = 0

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

print(A - B)

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

A = 0
B = 0

for i in range(1, N+1):
    if i % 2 == 1:
        A += card[i-1]
    else:
        B += card[i-1]

print(A -B)

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

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

A = sorted(A,reverse = True)

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

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

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

sorted_list = sorted(a,reverse = True)

Alice,Bob = 0,0 

for i in range(n):
    if i % 2 == 0:
        Alice += sorted_list[i]
    else:
        Bob += sorted_list[i]

ans = Alice - Bob
print(ans)

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

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

a.sort(reverse=True)

alice_score = 0
bob_score = 0

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

print(alice_score - bob_score)

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

    alice = 0
    bob = 0

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

    print(alice - bob)


if __name__ == '__main__':
    main()

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

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

print(sum(li[::2]) - sum(li[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())
l = [int(i) for i in input().split()]
l = sorted(l, reverse=True)

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

print(alice-bob)

Solution (Python):
n = input()
nums = sorted(list(map(int, input().split())), reverse=True)
result = 0
for i, v in enumerate(nums):
    result += (1 if i % 2 == 0 else -1) * v
print(result)

Solution (Python):
n = int(input())
line = input().split(" ")
a = []
alice = 0
bob = 0

for i in line:
    a.append(int(i))

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())
arr=list(map(int, input().split()))
a, b=0, 0
for k, v in enumerate(sorted(arr, reverse=True)):
  if k%2==0:
    a+=v
  else:
    b+=v
print(a-b)

Solution (Python):


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

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

Solution (Python):
n = int(input())
A = sorted([int(i) for i in input().split()], 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)
b=0
c=0
if n%2==0:
    for i in range(n//2):
        b+=a[2*i]
        c+=a[2*i+1]
else:
    for i in range(n//2):
        b+=a[2*i]
        c+=a[2*i+1]
    b+=a[n-1]
if b>c:
    print(b-c)
else:
    print(c-a)

Solution (Python):
N = int(input())
cards = list(map(int,input().split()))
alice,bob = 0, 0
for i in range(N):
    choice = cards.pop(cards.index(max(cards)))
    if i % 2 == 0:
        alice += choice
    else:
        bob += choice
print(alice-bob)

Solution (Python):
tmp = int(input())
num = sorted(list(map(int,input().split())),reverse=True)
bob = 0
mary = 0
for i in range(tmp):
  if i%2 == 0:
    mary += num[i]
  else:
    bob += num[i]
print(str(mary -bob))

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

a_sort = sorted(a)[::-1]
Alice = 0
Bob = 0
for i in range(0,N):
	if i%2 == 0:
		Alice += a_sort[i]
	if i%2 == 1:
		Bob += a_sort[i]

print(Alice-Bob)

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

alice = 0
bob = 0
is_alice_turn = True
while 0 < len(a):
    if is_alice_turn:
        alice += a[len(a) - 1]
    else:
        bob += a[len(a) - 1]
    a.pop(len(a) - 1)
    is_alice_turn = not is_alice_turn
print(alice - bob)

Solution (Python):
def main(N,xs):
    
    xs.sort(reverse=True)
    alice = xs[0::2]
    bob = xs[1::2]
    print(sum(alice)-sum(bob))
    return

if __name__ == '__main__':
    N = int(input())
    xs = list(map(int,input().split()))
    main(N,xs)

Solution (Python):
def main(N,xs):
    
    xs.sort()
    xs.reverse() 
    alice = 0
    bob = 0
    for i,x in enumerate(xs):
        if i % 2 == 0:
            alice += x
        else:
            bob += x
    print(alice-bob)
    return

if __name__ == '__main__':
    N = int(input())
    xs = list(map(int,input().split()))
    main(N,xs)

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

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse = True)
s = []
d = []
for i in range(0,n,2):
    s.append(a[i])
for j in range(1,n,2):
    d.append(a[j])
print(sum(s)-sum(d))

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
a.sort(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):
count = int(input())
array = sorted(list(map(int, input().split())), reverse=True)
r = 0
i = 0
while i < count:
    if (i % 2) < 1:
        r += array[i]
    else:
        r -= array[i]
    i += 1
    
print(r)

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

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

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

Solution (Python):
import numpy as np
N = int(input())
value = np.sort(list(map(int,input().split())))[::-1]
print(np.sum(value[::2]) - np.sum(value[1::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):
import numpy as np
N = int(input())
value = list(map(int,input().split()))
value=np.sort(value)[::-1]

a = np.sum(value[::2])
b = np.sum(value[1::2])
print(a-b)

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

Solution (Python):
alice = 0
bob= 0

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

for i in range(N):
    max_num = max(a)
    if i % 2 == 0:
        alice += max_num
    else:
        bob += max_num
    a.remove(max_num)

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):
  ans+=(-1)**i * A[i]
print(ans)

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

alice = 0
bob = 0
for i in range(0, N):
    m = max(A)
    if i % 2 == 0: 
        alice += m
    else:
        bob += m
    A.remove(m)
print(alice-bob)

Solution (Python):

 



 
 
n=int(input())
line=list(map(int,input().split( )))
 
line=sorted(line)
 

 
s=sum([line[-(i+1)] for i in range(n) if i%2==0])-sum([line[-(i+1)] for i in range(n) if i%2!=0])
 
print(s)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a.sort()
x=y=0
while True:
  if len(a)>0:
    x+=a.pop()
  else:
    break
  if len(a)>0:
    y+=a.pop()
  else:
    break
print(x-y)

Solution (Python):
N = int(input())
a = input().split()
for i in range(N):
    a[i] = int(a[i])
Alice = 0
Bob = 0
a.sort(reverse=True)
for i in range(N):
    if(i%2==0):
        Alice = Alice + a[i]
    else:
        Bob = Bob + a[i]
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 = input()
As = list(map(int, input().split()))

Alice = []
Bob = []

while(As):
    Alice.append(max(As))
    As.remove(max(As))
    if not As:
        break
    Bob.append(max(As))
    As.remove(max(As))

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

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

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

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

cards = sorted(cards, reverse=True)

print(2*sum(cards[0::2]) - sum(cards))

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()
a.reverse()
alice,bob = 0,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 = 0
B = 0
for i in range(N):
    m = max(a)
    x = a.index(m)
    if i % 2 == 0:
        A += m
    else:
        B += m
    a[x] = 0
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):
import numpy as np
input()
cards = np.array(list(input().split()), dtype=int)

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

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

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

d=sum(c[0::2])
e=sum(c[1::2])
print(abs(e-d))

Solution (Python):
N = int(input())
a = list(map(int,input().split()))
a.sort()
a.reverse()
Alice = []
Bob = []
if N % 2 == 0:
    for i in range(N//2):
        Alice.append(a[i*2])
        Bob.append(a[i*2+1])
    print(sum(Alice) - sum(Bob))
elif N % 2 == 1 and N != 1:
    for i in range((N-1)//2):
        Alice.append(a[i*2])
        Bob.append(a[i*2+1])
    Alice.append(a[-1])
    print(sum(Alice) - sum(Bob))
elif N == 1:
    print(a[0])

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

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

Solution (Python):
input()
l=sorted([int(_) for _ in input().split()])[::-1]
print(sum(l[::2])-sum(l[1::2]))

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

Solution (Python):
n = int(input())
li = list(map(int, input().split()))
li.sort(reverse = True)
print(abs(sum(li[::2]) - sum(li[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())
l = list(map(int, input().split()))
l.sort(reverse=True)

alice = 0
bob = 0

for i in range(0, n, 2):
    alice += l[i]

for i in range(1, n, 2):
    bob += l[i]

print(alice - bob)

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

sort_list = sorted(a)
rev_list = list(reversed(sort_list))

alice_sum = 0
bob_sum = 0

alice = rev_list[::2]
bob = rev_list[1::2]

for i in alice:
    alice_sum += i
for i in bob:
    bob_sum += i

ans = alice_sum - bob_sum

print(ans)

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

sum = 0
i = 0
while len(a_list) > 0:
    number = a_list.pop(a_list.index(max(a_list)))
    if i % 2 == 0:
        sum += number
    else:
        sum -= number
    i += 1
print(sum)

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

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

print(alice - bob)

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

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

Solution (Python):
import sys

input = sys.stdin.readline


def ii():
    return int(input())


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


N = int(input())
A = sorted(il())[::-1]
print(sum(A[::2]) - sum(A[1::2]))

Solution (Python):


import sys
input = sys.stdin.readline

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

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):
N = int(input())
num = [int(i) for i in input().split()]
num.sort(reverse=True)
a, b = 0, 0

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

print(a-b)

Solution (Python):


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

for t in range(N):
    for i in range(N-t):
        if A[t]<A[t+i]:
            b=A[t+i]
            A[t+i]=A[t]
            A[t]=b
Alice = 0
Bob = 0

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

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

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

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

a.sort()
a.reverse()

for i in range(int(n/2)):
        alice+=int(a[2*i])
        bob+=int(a[2*i+1])
if n%2==1:
        alice+=int(a[n-1])

ans=alice-bob
print(ans)

Solution (Python):

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





Alice_list = []
Bob_list = []

while True:

    
    max_idx = a_i.index(max(a_i))

    
    Alice_list.append(a_i[max_idx])
    a_i.remove(a_i[max_idx])

    
    if len(a_i)==0:
        break
        
        
    
    max_idx = a_i.index(max(a_i))

    
    Bob_list.append(a_i[max_idx])
    a_i.remove(a_i[max_idx])

    
    if len(a_i)==0:
        break
    

Alice_sum = sum(Alice_list)


Bob_sum = sum(Bob_list)


Alice_Bob = Alice_sum - Bob_sum


print(Alice_Bob)

Solution (Python):
N = int(input())
A = input().split(" ")
A = [int(i) for i in A]
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):



def calcAlice(cardList):
	cardMany = len(cardList)
	alicePoint = 0
	checkRange = range(0,cardMany,+2)
	for i in checkRange:
		alicePoint = alicePoint + cardList[i]
	return alicePoint

def calcBob(cardList):
	cardMany = len(cardList)
	bobPoint = 0
	checkRange = range(1,cardMany,+2)
	for i in checkRange:
		bobPoint = bobPoint + cardList[i]
	return bobPoint

def  diffTwoScore(allCards,cardsNumberGivenList):
	cardNumberSortedList=sorted(cardsNumberGivenList,reverse=True)
	getScoreForAlice = calcAlice(cardNumberSortedList)
	getScoreForBob = calcBob(cardNumberSortedList)
	diffPoint = getScoreForAlice - getScoreForBob
	answer = diffPoint
	return answer


if __name__ == '__main__':
	N = int(input().strip())
	cardsNumberRawList = list(map(int,input().strip().split(' ')))
	solution=diffTwoScore(N,cardsNumberRawList)
	print("{}".format(solution))

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

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

Alice = 0
Bob = 0
count=0
B = []
for i in A:
    B.append(i)

for i in range(len(B)):
    if(count==0):
        Alice+=max(B)
        count=1
        index = B.index(max(B))
        B[index] = 0
    else:
        Bob+=max(B)
        count=0
        index = B.index(max(B))
        B[index] = 0

print(Alice - Bob)

Solution (Python):
def main():
    n = int(input())
    aa = sorted(map(int, input().split()), reverse=True)
    print(sum(aa[0::2]) - sum(aa[1::2]))


if __name__ == '__main__':
    main()

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

Solution (Python):


def main():
    sn = input()
    sa = input().split(' ')
    a = [int(s) for s in sa]

    a.sort()
    a.reverse()
    na = 0
    nb = 0
    for n in a[0::2]:
        na += n
    for n in a[1::2]:
        nb += n

    print(na - nb)


if __name__ == '__main__':
    main()

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


abc088_b()

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
alice = 0
bob = 0
for i in range(0, 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
for i in range(N):
    ai=max(a)
    if i%2:
        Bob+=ai
    else:
        Alice+=ai
    a.remove(ai)

print(Alice-Bob)

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

player = [0,0]
turn = 0
count = 0

while(1):
    count+=1
    mx = max(le)
    player[turn]+=mx
    le.remove(mx)
    if count==N:
        break
    if turn==0:
        turn=1
    else:
        turn=0


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

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

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

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

a,b=0,0

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

print(a-b)

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

Solution (Python):
n = int(input())
dat = list(input().split())

dat = list(map(int,dat))

dat.sort(reverse=True)

asum = 0
bsum = 0

for i in range(n):
	if i % 2 == 0:
		asum = asum + dat[i]
	else:
		bsum = bsum + dat[i]
		
print(asum-bsum)

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

cards_num.sort(reverse=True)

bob = []
alice = []

for j in range(len(cards_num)):
    if j % 2 == 0:
        bob.append(cards_num[j])
    else:
        alice.append(cards_num[j])

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

Solution (Python):
N=int(input())
a=input().strip().split(" ")
a=[int(i) for i in a]
kisuu=0
guusu=0

a.sort(reverse=True)

for i in range(N):
    if(i%2==1):
       kisuu+=a[i]
    else:
        guusu+=a[i]

print(abs(kisuu-guusu))

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

a.sort(reverse=True)
score_of_alice, score_of_bob = 0, 0
for i in range(n):
    score = a.pop(0)
    if i % 2 == 0:
        score_of_alice += score
    else:
        score_of_bob += score

print(score_of_alice - score_of_bob)

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

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

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

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

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

Solution (Python):
N = input()
A = list(map(int, input().split(" ")))
A.sort(reverse=True)
alice = sum([j for i,j in enumerate(A) if i % 2 == 0])
bob = sum([j for i,j in enumerate(A) if i % 2 != 0])
print(alice - bob)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
alice, bob = 0, 0
for i in range(n):
    temp_max = max(a)
    a.remove(temp_max)
    if i % 2 == 0:
        alice += temp_max
    else:
        bob += temp_max
print(alice - bob)

Solution (Python):
times = int(input())
ans = 0
type = 1
num = list(map(int,input().split(" ")))
num.sort(reverse=True)
for i in num:
    if type % 2:
        ans += i
    else:
        ans -= i
    type += 1
    
print(ans)

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

list_a.sort()

sum_of_diff = 0

while list_a:
	tmp_a = list_a.pop()
	try:
		tmp_b = list_a.pop()
	except:
		tmp_b = 0
	sum_of_diff += tmp_a - tmp_b

print(sum_of_diff)

Solution (Python):
(lambda _, L: print(sum(L[0::2]) - sum(L[1::2])))(input(), sorted([int(i) for i in input().split()], reverse=True))

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

a.sort(reverse=True)

ali = []
bli = []

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

Solution (Python):
n = int(input())
a_list = [int(x) for x in input().split()]
alice = bob = 0
for i, a in enumerate(sorted(a_list, reverse=True)):
    if i % 2 == 0:
        alice += a
    else:
        bob += a
print(alice - bob)

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

c = sorted(b,reverse = True)
d = c[0::2]
e = c[1::2]

print(sum(d) - sum(e))

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

ans=0
flag=1
for i in range(n):
  ans+=(-1)**(i%2)*int(a[-1-i])
print(int(ans))

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

ans=0
flag=1
for i in range(n):
  ans+=flag*int(a[-1-i])
  flag=-1*flag
print(int(ans))

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

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

print(int(ans))

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

Solution (Python):

input()
print(sum(i if p % 2 == 0 else -i for p, i in enumerate(sorted(list(map(int, input().split())), reverse=True))))

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(int(i) for i in 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)
print(sum(a[0::2]) - sum(a[1::2]))

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

a.sort(reverse=True)
score_of_alice = score_of_bob = 0
for i, a_i in enumerate(a):
    if i % 2 == 0:
        score_of_alice += a_i
    else:
        score_of_bob += a_i

print(score_of_alice - score_of_bob)