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()))
a.sort(reverse=True)

i = 0
A = 0
B = 0
while i < N:
    A += a[i]
    if i+1 < N:
        B += a[i+1]
    i += 2
print(A - B)

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

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

    a_lst = sorted(a_lst)
    alice_score = 0
    bob_score = 0
    for _ in range(0,N,2):
        alice_score += a_lst.pop() if a_lst else 0
        bob_score += a_lst.pop() if a_lst else 0
    print(alice_score - bob_score)

main()

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

def main(n,a):
    a.sort(reverse=True)
    nloop=n//2
    apoint=0
    bpoint=0
    l=0
    while(l<nloop):
        apoint+=a[l*2]
        bpoint+=a[l*2+1]
        l+=1
    if(n%2==1):
        apoint+=a[n-1]
    return apoint-bpoint


if __name__=='__main__':
    n,a = readinput()
    ans=main(n,a)
    print(ans)

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

sorted_A = sorted(A, reverse=True)

Alice_sum = 0
Bob_sum = 0
for i in range(len(sorted_A)):
    if i % 2 == 0:
        Alice_sum = Alice_sum + sorted_A[i]
    else:
        Bob_sum = Bob_sum + sorted_A[i]

print(Alice_sum - Bob_sum)

Solution (Python):
n = int(input())
a = list(map(lambda x:int(x),input().split()))
a.sort(reverse=True)
al = 0
bo = 0
if n==1:
  al = a[0]
else:
  for i in range(0,n,2):
    al += a[i]
  for i in range(1,n,2):
    bo += a[i]
print(al-bo)

Solution (Python):
def resolve():
    
    n = int(input())
    
    
    
    
    
    A = list(map(int, input().split()))
    
    

    re = 0
    B = sorted(A, reverse=True)

    for i in range(len(B)):
        if i % 2 == 0:
            re += B[i]
        else:
            re -= B[i]
    print(re)
resolve()

Solution (Python):
def resolve():
    
    n = int(input())
    
    
    
    
    
    A = list(map(int, input().split()))
    
    

    sumA=0
    sumB=0
    B = sorted(A, reverse=True)
    turnB = False

    for i in B:
        if turnB == False:
            sumA += i
            turnB = True
        else:
            sumB += i
            turnB = False

    print(int(sumA - sumB))


resolve()

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

Gap = sum(A)
n = N//2

if N!=1:
    for i in range(n):
       Gap += -2*A[1+2*i]

print(Gap)

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

Gap = sum(A)

if N!=1:
    for i in range(N//2):
       Gap += -2*A[1+2*i]

print(Gap)

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

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

print(Alice-Bob)

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

if N == 1:
	print(A[0])
else:
	Alice = sum(A[0::2])
	Bob = sum(A[1::2])
	print(Alice-Bob)

Solution (Python):
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  
    a_arr = list(map(int,_in[1].split(' ')))
    
    a_arr.sort(reverse=True)
    alice_card = a_arr[0::2]
    bob_card = a_arr[1::2]
    cnt = sum(alice_card) - sum(bob_card)
    
    print(cnt)

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

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

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

Alice = 0
Bob = 0

for i in range(N):
  MaxPoint = max(cards)
  
  if i % 2 == 0:
    Alice += MaxPoint
  else:
    Bob   += MaxPoint

  cards.remove(MaxPoint)

print(Alice - Bob)

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

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

print(a-b)

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7


n=I()
alice,bob=0,0
u=sorted(LI(),reverse=True)
for i in range(n):
    if i%2==0:
        alice+=u[i]
    else:
        bob+=u[i]
print(alice-bob)

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

S = sorted(num_list, reverse=True)

Alice = S[::2]
Bob = S[1::2]

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

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

a = sorted(a, reverse=True)

alice = [a[2*i] for i in range(N) if 2*i<N]
bob = [a[2*i+1] for i in range(N) if (2*i+1)<N]

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

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

alice_count = 0
bob_count = 0

for i in range(0,N):
    
    if i%2==0: 
        alice_count += a_sorted[i]
    else: 
        bob_count += a_sorted[i]
        
print(alice_count-bob_count)

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

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

alice = 0
bob = 0

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

print(abs(alice - bob))

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

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

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

Solution (Python):
_ = input()
a,b = 0,0
cards = list(map(int, input().split()))
for i, c in enumerate(reversed(sorted(cards))):
  if i % 2 == 0:
    a += c
  else:
    b += c
print(a-b)

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

x.sort()
x.reverse()

A = []
B = []
for i in range(len(x)):
  if i%2==0:
    m = max(x)
    A.append(m)
    x.remove(m)
  else:
    m = max(x)
    B.append(m)
    x.remove(m)

C = sum(A) - sum(B)
print(C)

Solution (Python):

"""this is python work script"""

def find_score(card_list):
    """return score list about a and b"""
    sum_a, sum_b = 0, 0
    card_list.sort()
    
    for i in range(len(card_list)):
        if i % 2 == 0:
            sum_a += card_list.pop()
        else:
            sum_b += card_list.pop()
            
    return sum_a, sum_b

def solve(card_list):
    """solve problem"""
    a_score, b_score = find_score(card_list)
    diff_score = a_score - b_score
    
    return diff_score

def main():
    """main method"""
    _ = input()
    list_cards = list(map(int, input().split(' ')))
    answer = solve(list_cards)
    print(answer)

if __name__ == '__main__':
    main()

Solution (Python):

"""this is python work script"""

def find_score(N, card_list):
    """return score list about a and b"""
    sum_a, sum_b = 0, 0
    card_list.sort()
    for i in range(N):
        if i % 2 == 0:
            sum_a += card_list.pop()
        else:
            sum_b += card_list.pop()
    return sum_a, sum_b

def solve(num, card_list):
    """solve problem"""
    a_score, b_score = find_score(num, card_list)
    diff_score = a_score - b_score
    return diff_score

def main():
    """main method"""
    num_cards = int(input())
    list_cards = list(map(int, input().split(' ')))
    answer = solve(num_cards, list_cards)
    print(answer)

if __name__ == '__main__':
    main()

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

a = list(map(int,input().split()))
a.sort(reverse = True)
Alice = []
Bob = []
for i in range(N):
    if i%2 ==0:
        Alice.append(a[i])
    else:
        Bob.append(a[i])
print(sum(Alice) - sum(Bob))

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

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
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):
cnt = int(input())
numlist = list(map(int,input().split()))
list.sort(numlist, reverse=True)
A = 0
B = 0

for x in range(cnt):
    if x % 2 == 0:
        A += numlist[x]
    else:
        B += numlist[x]

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

A_point = 0
B_point = 0

for i in range(0, N):
    if i%2 == 0:
        A_point += a_sorted[i]
    else:
        B_point += a_sorted[i]

print(A_point-B_point)

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

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

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


def read():
    N = int(input().strip())
    A = (map(int, input().strip().split()))
    return N, A

def solve(N, A):
    A = sorted(A, reverse=True)
    alice = 0
    bob = 0
    alice_turn = True
    for a in A:
        if alice_turn:
            alice += a
        else:
            bob += a
        alice_turn = not alice_turn
    return alice - bob


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))

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

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

list_a.sort(reverse=True)

sam_a=0
sam_b=0

for i in range(N):
    if i%2 == 0:
        sam_a+=list_a[i]
    else:
        sam_b+=list_a[i]

print(sam_a-sam_b)

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

A=0
B=0
a=sorted(a,reverse=True)

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

print(A-B)

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

a_list.sort(reverse=True)
alice, bob = 0, 0
for idx, a in enumerate(a_list):
    if idx % 2 == 0:
        alice += a
    else:
        bob += a
print(alice - bob)

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

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

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

print(Alice-Bob)

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

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

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
Alice = 0
Bob = 0
b = 1
for i in range(N):
  if b: 
    Alice += a[i]
  else: 
    Bob += a[i]
  b = 0 if b == 1 else 1

print(Alice-Bob)

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

def sum(a):
    max_value = max(a)
    ind = a.index(max_value)
    a[ind] = 0
    return a,max_value

Asum = 0
Bsum = 0
max_value = 100
while max_value > 0:
    a,max_value = sum(a)
    Asum += max_value
    a,max_value = sum(a)
    Bsum += max_value

print(Asum - Bsum)

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

print(A - B)

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

for i in a [::2]:
    A += i
for i in a [1::2]:
    B += i

print(A - B)

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

alice = sorted(a)[::2]
bob = sorted(a)[1::2]

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

Solution (Python):















































N = int(input())
l = list(map(int,input().split()))
l_r = sorted(l,reverse=True)
Alice = l_r[::2]
Bob = l_r[1::2]

m =0
n = 0
for i in Alice:
    m += i
for j in Bob:
    n += j
print(m-n)

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

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

alices_score = sum([x if i % 2 == 0 else 0 for i, x in enumerate(l)])
bobs_score = sum([x if i % 2 != 0 else 0 for i, x in enumerate(l)])

print(alices_score - bobs_score)

Solution (Python):


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

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



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

print(Alice - Bob)

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

Alice = 0
Bob = 0

while len(a) > 0:
    m_a = max(a)
    Alice += m_a
    a.remove(m_a)

    if len(a) == 0:
        break
    else:
        m_a = max(a)
        Bob += m_a
        a.remove(m_a)

print(Alice-Bob)

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

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
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(" ")))
alice = []
bob = []
a.sort(reverse=True)
for k in range(int(n / 2) + 1):
    try:
        alice.append(a[2 * k])
        bob.append(a[2 * k + 1])
    except:
        pass
al = sum(alice)
bo = sum(bob)
res = abs(al - bo)
print(res)

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

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

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

score_a = 0
score_b = 0

for i, a in enumerate(sorted(A,reverse=True)):
    if i%2==0:
        score_a += a
    else:
        score_b += a
print(score_a-score_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())

s = input()
a=s.split(' ')
a=list(map(int,a))
a=sorted(a)
a.reverse()
flg=1
ans=0
for i in a:
    ans = ans + (i*flg)
    flg = flg*-1
print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
Alice = 0
Bob = 0
A.sort(reverse=True)
while len(A) > 0:
    Alice += A.pop(0)
    if len(A) > 0:
        Bob += A.pop(0)
print(Alice - Bob)

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

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

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


a=sorted(a,reverse=True)

score_a=0
score_b=0

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

print(score_a-score_b)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
a = LIST()

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

X.sort(reverse = True)

x = sum(X)
a = sum(X[0::2])

b = x - a

print(a-b)

Solution (Python):


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

    
    alice_sum = 0
    bob_sum = 0

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

    print(alice_sum - bob_sum)


main()

Solution (Python):
N = int(input())
List = [int(x) for x in input().split()]
Sum = sum(List)
List.sort(reverse=True)
del List[::2]
Sum_B = sum(List)
Sum_A = Sum-Sum_B
print(Sum_A-Sum_B)

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())
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())
a = list(map(int,input().split()))
a.sort(reverse=True)
ans = 0
for i in range(n):
    if i % 2 == 0:
        ans += a[i]
    elif i % 2 == 1:
        ans -= a[i]
        

print(ans)

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())
an = list(map(int,input().split()))
an_s = sorted(an, reverse=True)
alice = 0
bob =0


for i in range (n):
  if i%2 == 0:
    alice += an_s[i]
  elif i%2 != 0:
    bob += an_s[i]

ans = alice - bob
print(ans)

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

i = n
ca = 0
cb = 0
for i in range(n):
    if i%2 == 1:
        ca += a[i]
    else:
        cb += a[i]

print(abs(ca-cb))

Solution (Python):
N=int(input())
numbers=list(map(int,input().split()))
new_numbers=sorted(numbers,reverse=True)
Alice=0

Bob=0
for i in range(N//2+N%2):
    Alice+=new_numbers[2*i]
for i in range(N//2):
    Bob+=new_numbers[2*i+1]
print(Alice-Bob)

Solution (Python):
import math
n = int(input())
li=list(map(int,input().split()))
li.sort(reverse = True)
al = 0
bo = 0
for i in range(0, n, 2):
    al += li[i]
    if (n % 2 == 1 and i == n - 1):
        break
    bo += li[i + 1]
print(al-bo)

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

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

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

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

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

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

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

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

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

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

a_n = sorted(a_n, reverse=True)

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

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

Solution (Python):
Alice = 0
Bob = 0

N = int(input())
A = [None] * N
A = list(map(int, input().split()))

for i in range(N):
    if i % 2:
        Bob = Bob + max(A)
        A.remove(max(A))
    else:
        Alice = Alice + max(A)
        A.remove(max(A))

print(Alice - Bob)

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

B=sorted(A,reverse=True)
alice_num=0
bob_num=0

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

print(alice_num-bob_num)

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 = sorted(list(map(int, input().split())), reverse = True)
Alice = 0
Bob = 0
i = 0

for b in a:
    if (i % 2)==0: Alice += b
    else: Bob += b
    i += 1
print((Alice-Bob))

Solution (Python):
N=int(input())
A_list=list(map(int, input().split()))
A_list = sorted(A_list, reverse=True)
total = 0
for i in range((N+1)//2):
  total = total + A_list[i*2]
print(total-(sum(A_list)-total))

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):
i = int(input())
nums = list(map(int,input().split()))
num = sorted(nums,reverse=True)
a = 0
b = 0
for index,n in enumerate(num):
	if (index+1)  % 2 != 0:
		a += n
	else:
		b += n
print(a-b)

Solution (Python):

N = int(input())

X = list(map(int,input().split()))
Y=X.copy()
A=[]
B=[]
while Y:
    a=max(Y)
    A.append(a)
    Y.remove(a)
    if not Y:
        break
    b=max(Y)
    B.append(b)
    Y.remove(b)
print(sum(A)-sum(B))

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

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

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

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

point_a=0
point_b=0




while max(a)>0:
    
    point_a+=max(a)
    
    a[a.index(max(a))]=0
    
    point_b+=max(a)
    
    a[a.index(max(a))]=0


print(point_a-point_b)

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

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a.sort()
A = a[1::2]
B = a[0::2]
ScoreA = sum(A)
ScoreB = sum(B)
C = abs(ScoreA - ScoreB)
print(C)

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

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

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

aList.sort(reverse = True)

ap = 0
bp = 0

for i,a in enumerate(aList):
    if i%2 == 0: 
        ap = ap + a
    else:
        bp = bp + a
print(ap-bp)

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

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

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

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 == 1)

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 += a[i] * (-1 if i & 1 else 1)
print(ans)

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

Solution (Python):



import sys





def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(cardNumberList):
    result = 0
    cardNumberList.sort(reverse=True)

    
    
    for j in range(0, len(cardNumberList), +2):
        result = result + cardNumberList[j]
    
    for j in range(1, len(cardNumberList), +2):
        result = result - cardNumberList[j]
    return result


if __name__ == "__main__":
    _ = II()
    AI = LI()
    print("{}".format(solver(AI)))

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

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

def readlines(n):
    for i in range(n):
        for j, x in enumerate(input().split()):
            yield int(x), (i, j)


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


main()

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

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

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

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

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

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

Solution (Python):
import numpy as np

n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
a = np.array(a)

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

print(alice-bob)

Solution (Python):
N = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
count = 1
A = []
B = []
for a in l:
    if count % 2 == 1:
        A.append(a)
    else:
        B.append(a)
    count += 1
print(sum(A) - sum(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())
a = list(map(int, input().split()))
Alice = 0
Bob = 0
for i in range(N):
  if (i+1)%2 == 1:
    Alice += max(a)
    a.remove(max(a))
  else:
    Bob += max(a)
    a.remove(max(a))
print(Alice - Bob)

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    a=list(map(int,input().split()))
    a.sort(reverse=1)
    print(sum(a[::2])-sum(a[1::2]))

if __name__ == '__main__':
    main()

Solution (Python):

N = int(input())
a = [int(i) for i in input().split()]
Alice = 0
Bob = 0
count = 0
while not all((x == 0 for x in a)):
  if count%2 == 0:
    max_value = max(a)
    Alice += max_value
    max_index = a.index(max_value)
    a[max_index] = 0
    count += 1
  elif count%2 == 1:
    max_value = max(a)
    Bob += max_value
    max_index = a.index(max_value)
    a[max_index] = 0
    count += 1
print(abs(Alice - Bob))

Solution (Python):
N = int(input())
li = list(map(int,input().split()))
li.sort(reverse=True)
Alice = 0
Bob = 0
for i in range(1,N+1):
    if i%2 !=0:
        Alice+=li[i-1]
    elif i%2 == 0:
        Bob += li[i-1]
ans = Alice-Bob
print(ans)