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 = list(map(int, input().split()))
alice_sum = 0
bob_sum = 0
turn = 1
a.sort(reverse=True)
for i in range(n):
    if turn == 1:
        alice_sum += a.pop(0)
    else:
        bob_sum += a.pop(0)
    turn *= (-1)
print(alice_sum-bob_sum)

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

bob = 0
alice = 0

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

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

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

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

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

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

print(A - B)

Solution (Python):
N, i = [input() for x in range (2)]
arr = sorted([int(y) for y in i.split(' ')], reverse=True)

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

Solution (Python):
def main():
    N = int(input())
    A = sorted([int(a) for a in input().split()], reverse = True)
    Alice = 0
    for i in range(N):
        if i % 2 == 0:
            Alice += A[i]
    return 2*Alice - sum(A)

if __name__ == '__main__':
    print(main())

Solution (Python):
import math
N = int(input())
M = list(map(int, input().split()))
alice = 0
bob = 0
M.sort()
for i in range(math.ceil(N/2)): 
    alice += M[2*i]
    if N % 2 != 0 and i == int(N/2):
        break
    bob += M[2*i+1]
print(abs(alice - bob))

Solution (Python):
from collections import deque
n = int(input())
lis = list(map(int,input().split()))
lis.sort(reverse=True)
q_li = deque(lis)
a = 0
b = 0
for l in range(n):
    if l % 2 == 0:
        a += q_li.popleft()
    else:
        b += q_li.popleft()
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 = [int(i) for i in input().split()]
alice = 0
bob = 0
 
a.sort()
for i in range(1, n+1, 2):
  alice += a[n-i]
  if n-i-1 >= 0:
    bob += a[n-i-1]

    
print(alice-bob)

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

while a != []:
  alice += max(a)
  a.remove(max(a))
  try:
  	bob += max(a)
  except:
    break
  try:
    a.remove(max(a))
  except:
    break
    
print(alice-bob)

Solution (Python):


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


a=sorted(a,reverse=True)

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()))
a.sort(reverse=True)
print(sum(a[::2]) - sum(a[1::2]))

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

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

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

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

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

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

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

alice = 0
bob = 0

for i in range(0, len(A), 2):
    alice += A[i]
    if len(A) > i + 1:
        bob += A[i + 1]

print(alice - bob)

Solution (Python):

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
Alice=0
Bob=0

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

while len(A)>=1:
    Alice+=A.pop(0)
    Bob+=A.pop(0)
print(Alice-Bob)

Solution (Python):
n = int(input())
a = sorted(list(map(int,input().split())))[::-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(sorted(map(int, input().split())))[::-1]
if N % 2 == 1:
    a += [0]
print(sum(a[::2]) - sum(a[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):
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())
cards = list(map(int, input().split()))

cards.sort(reverse = True)
sum_A = 0
sum_B = 0


for i in range(N):
    if i % 2 == 0:
        sum_A += cards[i]
    else:
        sum_B += cards[i]

print(sum_A - sum_B)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
b=0
for j in range(0,n-1):
  for i in range(0,n-1):
    if a[i]<a[i+1]:
      b=a[i]
      a[i]=a[i+1]
      a[i+1]=b
num=0
for x in range(0,n//2):
  num=num+a[2*x]-a[2*x+1]
if n%2==1:
  num+=a[n-1]
print(num)

Solution (Python):
def searchMaxIndex(arr):
    if len(arr) == 0:
        return -1

    result = 0
    for i in range(len(arr)):
        if arr[i] > arr[result]:
            result = i

    return result

def pullValueBiIndex(arr, index):
    result = arr[index]
    arr.pop(index)
    return result

card_count = int(input())
cards = input()
cards = [int(value) for value in cards.split(' ')]

alice = 0
bob = 0

while len(cards) > 0:
    index = searchMaxIndex(cards)
    alice += pullValueBiIndex(cards, index)

    index = searchMaxIndex(cards)
    if index == -1:
        break
    bob += pullValueBiIndex(cards, index)

print(alice - bob)

Solution (Python):
N=int(input())
a = [int(i) for i in input().split()] 
sorted_a=sorted(a)
sum_A=0
sum_B=0
while sorted_a != []:
    sum_A+= sorted_a[-1]
    if len(sorted_a)!=1:
        sum_B+= sorted_a[-2]
    del sorted_a[-1]
    if sorted_a!=[]:
        del sorted_a[-1]

print(sum_A-sum_B)

Solution (Python):



a = int(input())

b = [int(s) for s in input().split()]
b.sort(reverse=True)
alice = sum(b[0::2])
bob   = sum(b[1::2])


print(alice - bob)

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

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

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

a_sort = sorted(a, reverse=True)

Asum = 0
Bsum = 0

for i in range(1, N+1):
  if i%2 != 0:
    Asum += a_sort[i-1]
  else:
    Bsum += a_sort[i-1]

print(Asum-Bsum)

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

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

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

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

res = 0

for i in range(N):
    if i % 2 == 0:
        res += a_list[i]
    if i % 2 == 1:
        res -= a_list[i]

print(res)

Solution (Python):
n=int(input())
a_list=list(input().split())
a_list = [int(n) for n in a_list]
a_list.sort(reverse=True)
a = 0
b = 0
for i in range(n):
    if i % 2 == 0:
        a += int(a_list[i])
    elif i % 2 == 1:
        b += int(a_list[i])
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):
input()
a=sorted(map(int,input().split()))[::-1]
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[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, ai in enumerate(a):
    if i % 2 == 0:
        alice += ai
    else:
        bob += ai

print(alice-bob)

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

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

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

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

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

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


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

print(b)

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

Solution (Python):
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
al = 0
bo = 0
for i, v in enumerate(a):
    if i % 2 == 0:
        al += v
    else:
        bo += v
print(abs(al - bo))

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

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

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

print(alice - bob)

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

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

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

for i in range(Num):

    if i % 2 == 0 :
        Alice += Num_Array[i]
    else:
        Bob   += Num_Array[i]

print(Alice - Bob)

Solution (Python):
Num = int(input())
Num_Array = list(map(int,input().split()))
Alice,Bob = 0,0

for i in range ( Num ):
    Check_Max = -1

    for x in range(len(Num_Array)):
        if Num_Array[x] > Check_Max :
            Check_Max = Num_Array[x]
            check = x

    Num_Array.pop(check)

    if i % 2 == 0 :
        Alice += Check_Max
    else:
        Bob += Check_Max

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 index, point in enumerate(sorted_A):

  
  if (index + 1) % 2 != 0:
    alice = alice + point
  
  
  else:
    bob = bob + point
 
answer = alice - bob

print(answer)

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

Solution (Python):
from itertools import zip_longest

def main():
    n, *a = map(int, open(0).read().split())
    a = reversed(sorted(a))
    res = sum(a - b for a, b in zip_longest(*[iter(a)]*2, fillvalue=0))
    print(res)


if __name__ == "__main__":
    main()

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

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

c.sort(reverse=True)
for i,j in enumerate(c):
  if i % 2 == 0:
    a += j
  else:
    b += j

print(a-b)

Solution (Python):
import math
N = int(input())
a = list(map(int, input().split()))
Alice = 0
Bob = 0
for i in range(1, math.floor(N / 2 + 1)):
    Alice += max(a)
    a.remove(max(a))
    Bob += max(a)
    a.remove(max(a))
if N %2 != 0:
    Alice += max(a)
print(Alice - Bob)

Solution (Python):
N = int(input())
li = list(map(int,input().split()))
a = []
b = []

li.sort(reverse = True)
for i in li[0::2]:
  a.append(i)
for i in li [1::2]:
  b.append(i)
print(sum(a) - sum(b))

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

print(diff)

Solution (Python):
from sys import stdin

N = int(stdin.readline().rstrip())
a_lst = [int(x) for x in stdin.readline().rstrip().split()]

alice_sum = 0
bob_sum = 0

a_lst.sort(reverse=True)

for i, v in enumerate(a_lst):
  if i % 2 == 0:
    alice_sum += v
  else:
    bob_sum += v

print(alice_sum - bob_sum)

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

Bob=Alice = 0
loop=0

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

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

a = a.split()


for i in range(n):
	a[i] = int(a[i])

a	= sorted(a)
a.reverse()

alice = a[0]
bob = 0
for i in range(1, n):
	if i%2 == 0:
		alice = alice + a[i]
	else:
		bob = bob + a[i]
	
print(alice - 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):
def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    a.sort(reverse=True)
    sw = 0
    alice = 0
    bob = 0
    for i in a:
        if sw == 0:
            alice += i
            sw = 1
        else:
            bob += i
            sw = 0
    print(alice-bob)

if __name__ == '__main__':
    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())
an = list(reversed(sorted(map(int,input().split()))))
print(sum(an[::2])-sum(an[1::2]))

Solution (Python):
import sys
input1 = input().rstrip()
inputs = input().rstrip().split(' ')
inputs_list = list(inputs)
input1 = int(input1)

Alice = 0
Bob = 0

for i in range(input1):
    tmp = inputs_list[0]
    for j in range(len(inputs_list)):
        if (int(tmp) < int(inputs_list[j])):
            tmp = inputs_list[j]
    inputs_list.remove(tmp)
    if (i % 2 == 0):
        Alice += int(tmp)
    else:
        Bob += int(tmp)

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(reverse = True)
print (sum(a[::2]) - sum(a[1::2]))

Solution (Python):
n = int(input())
lis = list(map(int, input().split()))
lis = sorted(lis)
alice = 0
bob = 0
for i, value in enumerate(lis):
    if i % 2 != 0:
        alice += value
    else:
        bob += value
print(abs(alice - bob))

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

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

b = sorted(a, reverse = True)

total = 0
for i in range(len(b)):
    total = total + b[i] if i%2 == 0 else total - b[i]

print(total)

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







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


l.sort(reverse=True)



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

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

Solution (Python):

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

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

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

a.sort()
a.reverse()


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

print(alice - bob)

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

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

Solution (Python):
n = int(input())
cards = [int(i) for i in input().split()]
alice = 0
bob = 0

for j in range(n):
    if j%2 == 0:
        alice += cards.pop(cards.index(max(cards)))
    else:
        bob += cards.pop(cards.index(max(cards)))

print(alice - bob)

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

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

    print(alice - bob)


main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
n=int(input())
aa=list(sorted(map(int,input().split()),reverse=True))
print(sum(aa[::2]) - sum(aa[1::2]))

Solution (Python):
import numpy as np
n = int(input())
a = list(map(int, input().split()))
alice = 0
bob = 0
for i in range(n):
  if i % 2 == 0: 
    alice += a.pop(np.argmax(a))
  else: 
    bob += a.pop(np.argmax(a))
print(alice - bob)

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

Solution (Python):

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

print(a - b)

Solution (Python):
N = int(input())
numbers = [x for x in map(int, input().split())]
numbers.sort(reverse=True)
print(sum([numbers[x] for x in range(N) if x % 2 ==0]) 
      - sum([numbers[x] for x in range(N) if x % 2 ==1]))

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

A.sort(reverse=True)
l = 0
r = 0
for i, a in enumerate(A):
    if i % 2 == 0:
        l += a
    else:
        r += a
print(l-r)

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

sla=sorted(la,reverse=True)

a_li=[]
b_li=[]
for i in range(n):
    if(i%2==0):
        a_li.append(sla[i])
    else:
        b_li.append(sla[i])

print(sum(a_li)-sum(b_li))

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

alice = 0
bob = 0

a_list.sort(reverse=True)

for x in range(0, n, 2):
    alice += a_list[x]

for y in range(1, n, 2):
    bob += a_list[y]

print(alice - bob)

Solution (Python):

N = int(input())
card_list = [int(i) for i in input().split()]
alice = 0
bob = 0
for i in range(N):
    if i%2==0:
        m = max(card_list)
        alice += m
        card_list.remove(m)
    if i%2==1:
        m = max(card_list)
        bob += m
        card_list.remove(m)
print(alice-bob)

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

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

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

apoint = 0
bpoint = 0
while True:
	apoint += max(cards)
	cards.remove(max(cards), )

	if len(cards) == 0:
		break

	bpoint += max(cards)
	cards.remove(max(cards))

	if len(cards) == 0:
		break

dif = apoint - bpoint
print(dif)

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

Alice_score = 0
Bob_score = 0
for i in range(-(-N//2)): 
    Alice_score += max(a)
    a.remove(max(a))
    if len(a) == 0: 
        break
    Bob_score += max(a)
    a.remove(max(a))
print(Alice_score - Bob_score)

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

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

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

Solution (Python):
def intget():
    return int(input())

_n = intget()
ar = list(map(int, input().split()))
ar.sort()
ar.reverse()

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

print(alice - bob)

Solution (Python):
N=int(input())
AN=list(map(int,input().split()[:N]))
ANsort=sorted(AN,reverse=True)

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

Solution (Python):
n=int(input())
card=list(map(int,input().split()))
A=0
B=0
count=0
while len(card)!=0:
    point=max(card)
    if count%2==0:
        A +=point
    else:
        B +=point
    count +=1
    card.remove(point)
print(A-B)

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

print(sum(cards[::2]) - sum(cards[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(len(a)):
  if i % 2 == 0:
    alice += a[i]
  else:
    bob += a[i]
  
  
print( alice - bob )

Solution (Python):
n = input()
a_list = [int(num) for num in input().split()]

alice = 0
bob = 0

while True:
  if len(a_list) < 1:
    break
  next_num = max(a_list)
  alice += next_num
  a_list.remove(next_num)
  if len(a_list) < 1:
    break
  next_num = max(a_list)
  bob += next_num
  a_list.remove(next_num)

print(alice - bob)

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

a.sort();
result = 0;

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

print(abs(result))

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

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

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)
ali = sum(a[::2])
bo = sum(a[1::2])
print(ali-bo)

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

if len(a)%2 == 1:
    a = [0] + a

count = 0
for i in range(len(a)//2):
    count+=a[2*i+1]-a[2*i]
print(count)

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

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

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 = 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(abs(alice - bob))

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

a = 0
b = 0

card.sort(reverse=True)


for i in range(1,n+1):

  if i % 2 == 0:
    b = b + card[i-1]
  else:
    a += card[i-1]

print(a - b)

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

for i,a in enumerate(A):
    if i%2 == 0:
        Alice += a
    elif i%2 == 1:
        Bob += a
answer = Alice - Bob
print(answer)

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

a_list_descend = sorted(a_list, reverse=True)

diff = sum(a_list_descend[0::2]) - sum(a_list_descend[1::2])

print(diff)

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

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

a.sort(reverse=True)

for i in range(N):

    if i % 2 == 0:
        alice += a[i]
    else:
        bob += a[i]

print(alice - bob)

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

for i in range(0, n, 2):
    alice += a_list[i]
for i in range(1, n, 2):
    bob += a_list[i]
print(alice - bob)

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

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

Solution (Python):
if __name__ == '__main__':
    N = int(input())
    A = [None]*N
    A = list(map(int, input().split()))
    Alice = 0
    Bob = 0
    while(A):
        Alice += max(A)
        A.remove(max(A))
        if A:
            Bob += max(A)
            A.remove(max(A))
    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):
N = int(input())
cards_number = input()
numbers = list(map(int, cards_number.split()))
ordered_numbers = sorted(numbers, reverse=True)

alice_cards = []
bob_cards = []
while len(ordered_numbers) != 0:
    try:
        alice_cards.append(ordered_numbers.pop(0))
        bob_cards.append(ordered_numbers.pop(0))
    except IndexError:
        break

alice_point = sum(alice_cards)
bob_point = sum(bob_cards)

print(alice_point-bob_point)

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

even_indexes = list(num for num in range(0, N) if num % 2 == 0)
odd_indexes = list(num for num in range(0, N) if num % 2 == 1)
alice_cards = list(ordered_numbers[even_index] for even_index in even_indexes)
bob_cards = list(ordered_numbers[odd_index] for odd_index in odd_indexes)

alice_point = sum(alice_cards)
bob_point = sum(bob_cards)

print(alice_point-bob_point)

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

alice = 0
bob = 0

for i in range(1, n+1):
  
  if i % 2 != 0:
    card = max(a)
    alice += card
  else:
    card = max(a)
    bob += card
  
  a.remove(card)
  
print(alice - bob)

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

a=[]
a = list(map(int, input().split()))
a.sort()

a=a[::-1]
i=0
sum=0
while i<len(a):
  if i%2==0:
    sum=sum+a[i]
  else:
    sum=sum-a[i]
  i=i+1

print(sum)

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

n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
cnt_a = 0
cnt_b = 0
for i in range(n):
    if i%2 == 0:
        cnt_a += a[i]
    else:
        cnt_b += a[i]
print(cnt_a-cnt_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=sorted(a)
b,c=0,0
for i in range(n):
    if i%2==1:
        b+=a[-i-1]
    else:
        c+=a[-i-1]
print(c-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 = input()
ma = map(int, input().split())
ls = []
for m in ma:
  ls.append(m)
ls.sort()
jdg = 0
Alice = 0
Bob = 0

for l in reversed(ls):
  if jdg == 0:
    Alice = Alice + l
  else:
    Bob = Bob + l
  jdg = 1 - jdg

print(Alice - Bob)

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

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

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

Solution (Python):
import sys

lines = sys.stdin.read().splitlines()
cards = [int(v) for v in lines[1].split(" ")]
cards.sort(reverse=True)
alice = 0
bob = 0
l = len(cards)
for i in range(0, l, 2):
  alice += cards[i]
  if i + 1 < l:
    bob += cards[i+1]
print(alice - bob)

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

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

print(res)