Problem:
 Score: 200 points    Problem Statement  We have N cards. A number a_i is written on the i -th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.      Constraints   N is an integer between 1 and 100 (inclusive).  a_i \ (1 \leq i \leq N) is an integer between 1 and 100 (inclusive).         Input  Input is given from Standard Input in the following format:  N  a_1  a_2  a_3  ...  a_N       Output  Print Alice's score minus Bob's score when both players take the optimal strategy to maximize their scores.        Sample Input 1 2
3 1      Sample Output 1 2  First, Alice will take the card with 3 . Then, Bob will take the card with 1 .
The difference of their scores will be 3 - 1 = 2 .       Sample Input 2 3
2 7 4      Sample Output 2 5  First, Alice will take the card with 7 . Then, Bob will take the card with 4 . Lastly, Alice will take the card with 2 . The difference of their scores will be 7 - 4 + 2 = 5 . The difference of their scores will be 3 - 1 = 2 .       Sample Input 3 4
20 18 2 18      Sample Output 3 18

Solution (Python):
if __name__ == '__main__':
    N = int(input())
    a_list = list(map(int, input().split()))

    a_list = sorted(a_list, reverse=True)

    answer = 0
    for i in range(len(a_list)):
        if i % 2 == 0:
            if i + 1 <= len(a_list) - 1:
                answer += a_list[i] - a_list[i+1]
            else:
                answer += a_list[i]

    print(answer)

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

a.sort(reverse = True)

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

print(alice - bob)

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

alice = 0
bob = 0

a.sort(reverse = True)

i = 0

while True:
    if i >= n:
        break
    alice += a[i]
    i += 1
    if i >= n:
        break
    bob += a[i]
    i += 1

print(alice - bob)

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


def main():
    num = int(input())
    data = list(map(int, input().split()))
    data.sort(reverse=True)

    aaa = sum(data[::2])
    bbb = sum(data[1::2])

    print(aaa - bbb)



if __name__ == '__main__':
    main()

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

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

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

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

Solution (Python):
n = int(input())
cards = list(map(int, input().split()))
cards.sort(reverse=True)
alice = 0
bob = 0
alice_cards = cards[::2]
bob_cards = cards[1::2]
alice_sum = sum(alice_cards)
bob_sum = sum(bob_cards)
print(alice_sum - bob_sum)

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

n_list.sort(reverse=True)

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

Solution (Python):
import numpy as np

def main():
    N = int(input())
    a = np.array([int(_) for _ in input().split(" ")])

    Alice = np.array([])
    Bob = np.array([])

    turn = 1
    while len(a) != 0:
        if int(turn%2) != 0:
            Alice = np.append(a.max(), Alice)
        else:
            Bob = np.append(a.max(), Bob)

        a = np.delete(a, a.argmax())
        turn += 1

    print(int(Alice.sum() - Bob.sum()))

main()

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

Solution (Python):

def bSort(a):
    for i in range(len(a)):
        for j in range(len(a)-1, i, -1):
            if a[j] > a[j-1]:
                a[j], a[j-1] = a[j-1], a[j]

    return a

x = int(input())
cards = input()
card = cards.split(" ")
card = [int(s) for s in card]
bSort(card)
Alice = 0
Bob = 0

for i in range(0,len(card),2):
    Alice += int(card[i])
for i in range(1,len(card),2):
    Bob += int(card[i])
    
print(Alice - Bob)

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

a.sort() 

i = Alice = Bob = 0

while len(a) >= 1:
	if i % 2 == 0:
		Alice += a.pop(len(a)-1) 
	elif i % 2 != 0:
		Bob += a.pop(len(a)-1) 

	i += 1


print(Alice - Bob)

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

cardList.sort(reverse=True)

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

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

Solution (Python):

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


a.sort(reverse=True)

a_sum = 0
b_sum = 0

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

    elif i % 2 == 1:
        b_sum = b_sum + a[i]


print(a_sum - b_sum )

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

al = 0
bo = 0

for i in range(len(tmp)):
  if i %2 == 0:
    al = al + int(tmp[i])

  else:
    bo = bo + int(tmp[i])

print(al - bo)

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

Solution (Python):
input(); a = sorted(map(int, input().split()), reverse=True)
print(sum(a[0::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-1, -1, -2):
    if i >= 0:
        alice += A[i]
    if i >= 1:
        bob += A[i-1]

print(alice-bob)

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

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

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

Solution (Python):
import numpy as np
N = int(input())
a = [int(i) for i in input().split()]
a2 = sorted(a,reverse=True)
if (len(a2)%2!=0):a2+=[0]
print(-sum(np.diff(a2)[::2]))

Solution (Python):
n = int(input())
A = [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):
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)
ans = sum(a[::2]) - sum(a[1::2])
print(ans)

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

while a:
    al_val += max(a)
    a.remove(max(a))
    if not a: break
    bo_val += max(a)
    a.remove(max(a))

print(al_val - bo_val)

Solution (Python):

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


A_sort = sorted(A, reverse=True)


n = 0
m = 0
i = 0


for i in range(N):
	if i%2 == 0:
		n += A_sort[i]
	else:
		m += A_sort[i]


ans = n - m
print(ans)

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
if len(A) & 1:
  A.append(0)
A.sort()
print(sum([A[i+1]-A[i] for i in range(0, len(A), 2)]))

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
d=0
a.sort()
a.reverse()
for i in range(0,n,2):
 d+=a[i]
arisu=d
bobu=sum(a)-d

print(arisu-bobu)

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

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

ali = 0
bo = 0

while len(a) > 0:
    ali += a.pop(a.index(max(a)))
    if len(a) == 0:
        break
    bo += a.pop(a.index(max(a)))

print(ali - bo)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
list.sort(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(map(int, input().split()))
r = 0
for i in range(len(a)):
    m = max(a)
    a.remove(m)
    
    if i % 2 == 0:
        r += m
    else:
        r -= m
print(r)

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

card.sort(reverse=True)

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

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

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

for i in range(N//2):
    ali.append(A[i*2])
    bob.append(A[i*2+1])
if N%2==1:
    ali.append(A[-1])
    
        
print(sum(ali)-sum(bob))

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

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

t = sorted(t,key = lambda x:-x)

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

Solution (Python):
N = int(input())
A = [int(c) for c in 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):
from sys import stdin


def main():
    _ = int(stdin.readline().rstrip())
    a = [int(x) for x in stdin.readline().rstrip().split()]
    a = sorted(a, reverse=True)
    Alice = [x for i, x in enumerate(a) if i % 2 == 0]
    Bob = [x for i, x in enumerate(a) if i % 2 != 0]
    print(sum(Alice) - sum(Bob))


if __name__ == "__main__":
    main()

Solution (Python):
def ipt(N=0,switch=0):
    if N == 0:
        return list(map(int,input().split()))
    else:
        if switch==0:
            return [list(map(int,input().split())) for _ in range(N)]
        else:
            return [int(input()) for _ in range(N)]

input()
a=sorted(ipt(),reverse=True)
print(sum(a[::2])-sum(a[1::2]))

Solution (Python):
n = int(input())
a = [int(x) for x in input().split()]
sortA = sorted(a, reverse=True)
Alice = 0
Bob = 0
for i in range(len(a)):
    if i % 2 == 0:
        Alice+=sortA[i]
    else:
        Bob+=sortA[i]
    
print(Alice - Bob)

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

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

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

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())
m = list(map(int, input().split()))
m.sort(reverse=True)
a = 0
b = 0
t = True
for i in m:
  if t:
    a += i
  else:
    b += i
  t = True if not(t) else False
print(a-b)

Solution (Python):
_ = 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 = []
Bob = []
while len(A) != 0:
        Alice.append(A[0])
        A = A[1:]
        if len(A) != 0:
                Bob.append(A[0])
                A = A[1:]

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

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

x,y = 0,0

for i in range(0,n,2):
    x += b[i]
for i in range(1,n,2):
    y += b[i]

print(x-y)

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 = [int(i) for i in input().split()]
score_Alice = 0
score_Bob   = 0
turnA = True
a.sort(reverse = True)
for i in range(n):
  if turnA == True:
    score_Alice += a[i]
  else:
    score_Bob   += a[i]
  turnA = not turnA
print(score_Alice - score_Bob)

Solution (Python):
N = int(input())
s = list(map(int,input().split()))
s.sort()
alice = 0
bob = 0
for n in range((N+1)//2):
    alice += s[-1]
    del s[-1]
    try:
        bob += s[-1]
        del s[-1]
    except IndexError:
        break
print(alice-bob)

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

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

    a.sort(reverse = True)

    Alice, Bob = 0, 0

    for turn in range(0, len(a), 2):
        Alice += a[turn]

    for turn in range(1, len(a), 2):
        Bob += a[turn]

    print(Alice - Bob)

if __name__ == "__main__":
    main()

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

num_list = sorted(num_list)

point = 0
player = 1
while num_list:
    point += num_list.pop() * player
    player *= -1

print(point)

Solution (Python):
N = input()
a = list(map(int, input().split()))
a = sorted(a, reverse = True)
Alist = []
Blist = []
for i in range(len(a)):
    if i % 2 == 0:
        Alist.append(a[i])
    else:
        Blist.append(a[i])
print(sum(Alist) - sum(Blist))

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    a = f()

    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)

solve()

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

x = 0
y = 0

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

print(x - y)

X = []

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

Solution (Python):



n = int(input())
cards = list(map(int, input().split()))
a = 0
b = 0
for i in range(n):
    r = max(cards)
    if i % 2 == 0:
        a += r
    else:
        b += r
    cards.remove(r)
print(a-b)

Solution (Python):
N = int(input())
A = [int(s) for s in input().split()]
A.sort()
vA = 0;
vB = 0;
for i in range(N):
    if (len(A) == 0):
        break
    vA += A.pop()
    if (len(A) == 0):
        break
    vB += A.pop()
print(vA - vB)

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

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

for i in range(num):
  if i//2*2 == i:
    alice += cards[i]
  else:
    bob += cards[i]

print(alice - bob)

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

if num//2*2 == num:
  for i in range(num//2):
    alice += cards[i*2]
    bob += cards[i*2+1]
else:
  for i in range(num//2):
    alice += cards[i*2]
    bob += cards[i*2+1]
  alice += cards[num-1]

print(alice - bob)

Solution (Python):
n = int(input())
cards = list(map(int, input().split()))
remains = cards.copy()
alice, bob = [], []
while remains:
    a = max(remains)
    alice.append(a)
    remains.remove(a)
    if not remains:
        break
    b = max(remains)
    bob.append(b)
    remains.remove(b)
print(abs(sum(alice) - sum(bob)))

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

Solution (Python):
def main():
  N = int(input())
  arr = sorted([int(x) for x in input().split()])[::-1]
  print(sum(arr[0::2]) - sum(arr[1::2]))


if __name__ == "__main__":
  main()

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

A_sorted = sorted(A, reverse=True)

Alice_point = 0; Bob_point = 0

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

print(ans)

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

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

a.sort()
alice=[]
bob=[]
for i in range(n):
    x=a.pop(-1)
    if i%2==0:
        alice.append(x)
    else:
        bob.append(x)

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

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

a = sorted([int(x) for x in 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)
ans = 0
for i,ai in enumerate(a):
    if i%2==0:
        ans += ai
    else:
        ans -= ai
print(ans)

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

A=[]
B=[]

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

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

Solution (Python):
data = [input() for x in range(0, 2, 1)]

cards = [int(x) for x in data[1].split(" ")]


for i in range(0, len(cards), 1):
  
  for j in range(i + 1, len(cards), 1):
    
    if cards[i] < cards[j]:
      tmp1 = cards[i]
      tmp2 = cards[j]
      
      cards[i] = tmp2
      cards[j] = tmp1
      
alice = 0
bob = 0



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

Solution (Python):
def main():
  size = input()
  a = list(map(int, input().split()))
  a = merge_sort(a)
  
  alice_res = 0
  bob_res = 0
  
  for i in range(len(a)):
    if i%2 == 0:
      alice_res += a[i]
    else:
      bob_res += a[i]
 
  print(alice_res-bob_res)
  
 
def merge_sort(array):
  if len(array)<=1:
    return array
  
  spl_size = len(array)//2
  
  left_list = merge_sort(array[:spl_size])
  right_list = merge_sort(array[spl_size:])
  
  return merge_list(left_list, right_list)
 
 
def merge_list(left_list, right_list):
  left_index = 0
  right_index = 0
  sorted_list = []
  
  while left_index<len(left_list) and right_index<len(right_list):
    if left_list[left_index] < right_list[right_index]:
      sorted_list.append(right_list[right_index])
      right_index+=1
    else:
      sorted_list.append(left_list[left_index])
      left_index+=1
      
  if left_index == len(left_list):
    sorted_list.extend(right_list[right_index:])
  if right_index == len(right_list):
    sorted_list.extend(left_list[left_index:])
      
  return sorted_list
    
                          
main()

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

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


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


num.sort(reverse=True)

ans = sum(num[0::2]) - sum(num[1::2])

print(ans)

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

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

li.sort()
li.reverse()
ans = 0
for i in range(n):
  if i%2 == 0:
    ans += li[i]
  else:
    ans -= li[i]
print(ans)

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

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

Solution (Python):
N = 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 = Alice + A[i]
    else:
        Bob = Bob + A[i]

ans = (Alice - Bob)

print(ans)

Solution (Python):
import sys
import subprocess
import re
import datetime
import os

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 = Alice + A[i]
    else:
        Bob = Bob + A[i]

ans = (Alice - Bob)

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


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



nums.sort(reverse=True)



i = 0
Alis = 0
Bob = 0

for i in range(0,n):
    if i % 2 == 0:
        Alis = Alis + nums[i]
    else:
        Bob = Bob + nums[i]

print(Alis-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_0 = A.sort(reverse=True)
swt = 0
Alice_point = 0
Bob_point = 0

for i in range(n):
    if swt == 0:
        Alice_point += A[i]
        swt = 1
    else:
        Bob_point += A[i]
        swt = 0
print(Alice_point - Bob_point)

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

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

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

b = []
for i in range(N):
    b.append(max(a))
    a.remove(max(a))

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

result = Alice - Bob
print(result)

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

als = sum(a[::2])
bob = sum(a[1::2])

print(als - bob)

Solution (Python):
a = int(input())
card = list(map(int, input().split()))
card.sort(reverse=True)
Alice_card = []
Bob_card = []
for i in range(a):
    if i % 2 == 0:
        Alice_card.append(card[i])
    else:
        Bob_card.append(card[i])

Alice_point = sum(Alice_card)
Bob_point = sum(Bob_card)
Point = Alice_point - Bob_point
print(Point)

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

a.sort(reverse=True)
alice = a[0::2]
bob = a[1::2]

alice = sum(alice)
bob = sum(bob)
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):
def main():
    N = map(int, input().split())
    a = [int(s) for s in input().split()]
    a.sort(reverse = True)
    ans = 0
    ans = sum(a[0::2]) - sum(a[1::2])
    print(ans)


if __name__ == '__main__':
    main()

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

for i in range(N):
  max=0
  tmp=0
  for j in list:
    if max<j:
      max=j
      key=tmp
    tmp+=1
  if i%2==0:
    Alice+=max
  else:
    Bob+=max
  del list[key]
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()))
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())
s=list(map(int,input().split()))
s.sort(reverse=True)
a=[int(i) for i in s[::2]]
b=[int(j) for j in s[1::2]]
print(sum(a)-sum(b))

Solution (Python):

import sys
input = sys.stdin.readline

n = int(input())
lst = sorted(list(map(int, input().rstrip().split())), reverse=True)
total = 0
for i in range(n):
    if i % 2 == 0:
        total += lst[i]
    else:
        total -= lst[i]
print(total)

Solution (Python):

n = int(input())
lst = sorted(list(map(int, input().rstrip().split())), reverse=True)
total = 0
for i in range(n):
    if i % 2 == 0:
        total += lst[i]
    else:
        total -= lst[i]
print(total)

Solution (Python):
input()
print(sum(-k if i%2 else k for i,k in enumerate(sorted(map(int,input().split()),reverse=True))))

Solution (Python):
n=(int(input())+1)%2
print(sum(k if i%2==n else -k for i,k in enumerate(sorted(map(int,input().split())))))

Solution (Python):
_ = input()
print(sum(k if i%2 == 0 else -k for i,k in enumerate(sorted(map(int,input().split()),reverse=True))))

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

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())
numbers = list(map(int,input().split()))
alice = []
a = sum(numbers)
numbers.sort()
b = int(n/2)
if n%2 == 0 :
    for i in range(b) :
        alice.append(int(numbers[2*i+1])) 
else :
    for j in range(b+1) :
        alice.append(int(numbers[2*j])) 

x = sum(alice)
y = a - x
print(x - y)

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==1:
        A+=a[i]
    else:
        B+=a[i]
print(abs(A-B))

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

A.sort(reverse=True)
alice = sum([a for i, a in enumerate(A) if i%2 == 0])
bob   = sum([a for i, a in enumerate(A) if i%2 == 1])
print(alice - bob)

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

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

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

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

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

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

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


A.sort()
A.reverse()

Alice=0
Bob=0

for j in range(N):
    if j%2==0:
        Alice=Alice+A[j]
    else:
        Bob=Bob+A[j]

        
gap=Alice-Bob
print(gap)

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

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

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

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

print(ans)

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

Alice = 0
Bob = 0

num_list.sort(reverse=True)
for i, num in enumerate(num_list):
    if i % 2 == 0:
        Alice += num
    else:
        Bob += num

print(Alice - Bob)

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

Alice = 0
Bob = 0

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

print(Alice - Bob)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
alice = []
bob = []

for i in range(len(A)):
  max_n = max(A)
  A.remove(max_n)
  if i%2 == 0:
    alice.append(max_n)
  else:
    bob.append(max_n)
print(sum(alice) - sum(bob))

Solution (Python):
import sys

def main():
    n = int(input())
    a = sorted(list(map(int, input().split())), reverse=True)
    print(counter(n, a))

def counter(n, a):
    return sum(a[::2]) - sum(a[1::2])

if __name__ == '__main__':
    main()

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

a.sort()
alice=0
bob=0

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

for i in range(n//2):
    bob+=a[-2-2*i]

if n%2!=0:
    alice+=a[0]


print(alice-bob)

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

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

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

print(A - B)

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

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

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

print(alice - bob)

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

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