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):
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    a.sort(reverse=True)
    print(sum(a[0::2]) - sum(a[1::2]))


if __name__ == '__main__':
    slove()

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

	else:
		bob += a[i]

difference = alice - bob

print(difference)

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

result = 0
while len(a_n)>0:
    result +=a_n.pop()
    if len(a_n)>0:
        result  -=a_n.pop()
print(result)

Solution (Python):

import sys


def solve(N: int, a: "List[int]"):
    alice, bob = [0] * 2
    for i, v in enumerate(reversed(sorted(a))):
        if i % 2 == 0:
            alice += v 
        else:
            bob += v
    print(alice - bob)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    a = [int(next(tokens)) for _ in range(N)]  
    solve(N, a)

if __name__ == '__main__':
    main()

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

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

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

a_p = 0
b_p = 0

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

print(a_p - b_p)

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

Solution (Python):
import sys
from functools import reduce
import copy
import math
from pprint import pprint


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    cards = string_to_int(inputs[0])
    cards.sort(reverse=True)
    count_a = 0
    count_b = 0
    turn_a = True
    for card in cards:
        if turn_a:
            count_a += card
        else:
            count_b += card
        turn_a = not turn_a
    return count_a - count_b


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)

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

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

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

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

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

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

Solution (Python):

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

Solution (Python):

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

alice = 0
bob = 0
for i in range(n//2 + 1):
    if len(a) > 0:
        alice += a.pop(0)
    if len(a) > 0:
        bob += a.pop(0)

print(alice - bob)

Solution (Python):
n = int(input())
alice_cards = []
bob_cards = []
all_cards = list(map(int, input().split()))
all_cards.sort()
while len(all_cards) > 0:
    alice_cards.append(all_cards.pop(-1))
    if len(all_cards) == 0:
        break
    else:
        bob_cards.append(all_cards.pop(-1))
print(sum(alice_cards) - sum(bob_cards))

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

turn = 0
alice = 0
bob = 0

for i in range(n):
    turn += 1
    if turn%2 != 0:
        alice += max(a_list)
        
    else:
        bob += max(a_list)
    a_list.remove(max(a_list))

print(alice - bob)

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

a=sorted(a,reverse=True)
b=0
c=0

for i in range(0,N,2):
    b +=a[i]
    
for i in range(1,N,2):
    c +=a[i]


print(b-c)

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):
def bb088():
    n = int(input())
    an = list(map(int, input().split()))
    an.sort()

    a = 0
    b = 0
    for i in range(n-1, -1, -2):
        a += an[i]
        if i-1 >= 0:
            b += an[i-1]

    print(a-b)

bb088()

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

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

Solution (Python):
input()

alice = 0
bob = 0
is_alice = True
for n in sorted(map(int, input().split()), reverse=True):
    if is_alice:
        alice += n
    else:
        bob += n
    is_alice = not is_alice

print(alice - bob)

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

cards_number = len(cards)
for i in range(cards_number):
    if i % 2 == 0:
        alice.append(cards[i])
    else:
        bob.append(cards[i])

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

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

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

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

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

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

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
A = []
B = []
while True:
  A.append(max(a))
  a.remove(max(a))
  if len(a) == 0:
    break
  B.append(max(a))
  a.remove(max(a))
  if len(a) == 0:
    break
print(sum(A)-sum(B))

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

print(alice-bob)

Solution (Python):
n = int(input())
li = list(map(int,input().split())) 
li.sort(reverse = True)
a,b = 0,0
while li:
    a += li.pop(0)
    if len(li) == 0:
        break
    b += li.pop(0)
print(a-b)

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

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

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

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

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

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

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

c_L.sort(reverse=True)

alice,bob = 0,0

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

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

Solution (Python):
n = int(input())
c = list(map(int,input().split()))
a = 0
b = 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):
n = int(input())
a = sorted(list(map(int,input().split())))
print(abs(sum(a[::2])-sum(a[1::2])))

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

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

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


A=0
S=0
a.sort(reverse=True)
for i in range(N):
    S+=a[i]
    if i%2==0:
        A+=a[i]
print(abs(S-2*A))

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

Solution (Python):
s=input()
t=list(map(int,input().split()))
t.sort(reverse=True)
a=0
b=0
d=0
e=0
if len(t)%2==0:
  for i in range(0,len(t),2):
    d+=t[i]
    e+=t[i+1]
  print(d-e)
else:
  for j in range(0,len(t),2):
    d+=t[j]
  for l in range(1,len(t),2):
    e+=t[l]
  print(d-e)

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

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

Solution (Python):
N = int(input())
c = list(map(int, input().split()))
c.sort(reverse = True)
A = []
B = []
n = 0
for i in c:
    if n % 2 == 0:
        A.append(i)
    else:
        B.append(i)
    n += 1
print(sum(A) - sum(B))

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

print(sum)

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


a = 0
b = 0

isAlice = True

while n > 0:
    
    if isAlice:
        a += max(arr)
        isAlice = False
    else:
        b += max(arr)
        isAlice = True
    
    arr.remove(max(arr))
    n -= 1
    
print(a - b)

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

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


card_list.sort(reverse = True)

alice_list = []
bob_list = []
if N % 2 == 0:
    for i in range(0, N, 2):
        alice_list.append(card_list[i])
    for i in range(1, N, 2):
        bob_list.append(card_list[i])
else:
    for i in range(0, N + 1, 2):
        alice_list.append(card_list[i])
    for i in range(1, N, 2):
        bob_list.append(card_list[i])


alice_score = sum(alice_list)
bob_score = sum(bob_list)

ans = alice_score - bob_score
print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
asum = 0
bsum = 0
for a in A[0::2]:
  asum += a
for a in A[1::2]:
  bsum += a
print(asum - bsum)

Solution (Python):
N = int(input())
A = [int(a) for a in 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 = sum(a[0::2])
bob = sum(a[1::2])
print(alice - bob)

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

alice = sum([int(a[i]) for i in range(0, n, 2)])
bob = sum([int(a[i]) for i in range(1, n, 2)])

print(alice-bob)

Solution (Python):

def main():
    N, *A = map(int, open(0).read().split())
    A.sort(reverse=1)
    ans = sum(A[::2]) - sum(A[1::2])
    print(ans)


if __name__ == "__main__":
    main()

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

Solution (Python):
import numpy as np
import sys
n = int(input())
a = 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()))
list.sort(a, reverse=True)

goukei = 0

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

for i in range(0,len(a),2):
	goukei = goukei + (a[i] - a[i + 1])

print(goukei)

Solution (Python):
n=int(input())
a = list(map(int,input().split()))
a.sort(reverse = True)
A=0
B=0
for i in range(n//2+n%2):
    A+=a[i*2]
for i in range(n//2):
    B+=a[i*2+1]
print(A-B)

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

a.sort(reverse=True)
a_sum = sum(a[0:len(a):2])
b_sum = sum(a[1:len(a):2])

ans = a_sum-b_sum

print(ans)

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

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

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

alice = 0
bob = 0
for key, value in enumerate(l):
    if key % 2 == 0:
        alice += value
    else:
        bob += value
print(alice - bob)

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

Solution (Python):
n=int(input())
a=b=0
p=sorted(list(map(int,input().split())),key=int,reverse=True)
p.append(0)
for i in range(int((n+1)/2)):
    a+=p.pop(0)
    b+=p.pop(0)
print(a-b)

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
a.reverse()
b = a[::2]
c = a[1::2]
print(sum(b)-sum(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.sort()
a.reverse()
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([int(x) for x in input().split()], reverse=True)

Alice = sum(a[i] for i in range(0,N,2))
Bob = sum(a) - Alice
print(Alice-Bob)

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

Alice=a[0::2]
Bob = a[1::2]

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

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

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

alice_sum = 0
bob_sum = 0
for i in range(n):
    if i % 2 == 0:
        alice_sum += a_list[i]
    else:
        bob_sum += a_list[i]

print(alice_sum - bob_sum)

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

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
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:
        Bob = Bob + Cards[i]
    else:
        Alice = Alice + Cards[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):
N = int(input())
list_a = list(map(int, input().split()))

list_a.sort(reverse=True)
Alice_score = sum(list_a[::2])
Bob_score = sum(list_a[1::2])

print(Alice_score - Bob_score)

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

Alice_score = 0
Bob_score = 0

while len(list_a) > 0:
    Alice_score += list_a.pop(list_a.index(max(list_a)))
    if len(list_a) > 0:
        Bob_score += list_a.pop(list_a.index(max(list_a)))

print(Alice_score - Bob_score)

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

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

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

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

a.sort()
a.reverse()

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

array.sort(reverse=True)

a_sum = 0
b_sum = 0

for i in range(n):
    if i % 2 == 0:
        a_sum += array[i]
    else:
        b_sum += array[i]

print(a_sum - b_sum)

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

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

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

alice = 0
bob = 0

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

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

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

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)
Alice = [a[i] for i in range(N) if i % 2 == 0]

print(sum(Alice) * 2 - sum(a))

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

    score_of_Alice = 0
    score_of_Bob = 0

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

    print(score_of_Alice - score_of_Bob)

solve()

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
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n = ni()
a = na()
a.sort(reverse=True)
alice = sum(a[::2])
bob = sum(a[1::2])
print(alice - bob)

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

alis,bob = 0, 0
for i in range(N):
  if i%2 == 0:
    alis += max(an)
    an[an.index(max(an))]= 0
  elif i%2 == 1:
    bob += max(an)
    an[an.index(max(an))] = 0

print(alis - bob)

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

Solution (Python):



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


a.sort(reverse=True)


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

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

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

if len(a) % 2 == 1:
	A.append(min(a))
	a.remove(min(a))

while len(a) > 0:
	A.append(max(a))
	a.remove(max(a))
	B.append(max(a))
	a.remove(max(a))

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

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

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

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

ptA = 0
ptB = 0

for i in range(N):
    if i % 2 == 0:
        temp = max(a)
        ptA += temp
        a.remove(temp)
    else:
        temp = max(a)
        ptB += temp
        a.remove(temp)

print(ptA-ptB)

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

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

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

Solution (Python):
import numpy as np

N = int(input())

a_inputs = input().split()

a = np.zeros(N)
for i in range(N):
  a[i] = int(a_inputs[i])
  
a = np.sort(a)[::-1]

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

print(int(alice - bob))

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
alice = []
bob = []
a.sort()
a = a[::-1]
for i in range(n):
    if len(alice) > len(bob):
        bob.append(a[i])
    else:
        alice.append(a[i])
print(sum(alice) - sum(bob))

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

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

Alice=0
Bob=0

for i in range(1,N+1):
  if i%2 == 1:
    Alice+= aList[i-1]
  else :
    Bob+= aList[i-1]

print(Alice-Bob)

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

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

Solution (Python):



from math import *
import os
import sys


import numpy as np



if __name__ == "__main__":
    Input = [raw_input() for i in range(2)]
    N = int(Input[0])
    A = list(map(int,Input[1].split()))
    A.sort()
    A.reverse()
    Alise = sum([A[i] for i in np.arange(0,N,2)])
    Bob = sum(A)-Alise
    print Alise-Bob

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

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

for i in range(N):
    if i%2 == 0:
        Alice.append(A[i])
    elif i%2 == 1:
        Bob.append(A[i])

ans = sum(Alice) - sum(Bob)
print(ans)

Solution (Python):
import sys
import math
from fractions import gcd





def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""


 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())


 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


N =  int(sys.stdin.readline())
L =  list(map(int, sys.stdin.readline().split()))

L.sort(reverse=True)

ali= 0
bob = 0
for i, x in enumerate(L):
    if i % 2 == 0:
        ali += x
    else:
        bob += x
print(ali - bob)

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

a.sort(reverse=True)

A = a[0:N:2]
B = a[1:N:2]

print(sum(A)-sum(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())
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=1)
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):
  ans += a[i]*((-1)**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=sorted(list(map(int, input().split())),reverse=True)
x=sum(a[::2])
y=sum(a[1::2])
print(x-y)

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

while True:
    alice += a.pop(a.index(max(a)))
    if len(a) <= 0:
        break
    bob += a.pop(a.index(max(a)))
    if len(a) <= 0:
        break

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())
cards = list(map(int, input().split()))
cards.sort(reverse=True)
Alice=0
Bob=0
for i in range (len(cards)):
    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()))
Alice_score = 0
Bob_score = 0

a.sort(reverse = True)

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

print(Alice_score - Bob_score)

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

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

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

alice = 0
for i in range(0, N, 2):
  alice += a[i]

print(alice - sum(a) + alice)

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(reverse=True)
score = [0, 0]
for i in range(n):
    score[i%2] += a[i]

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

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

ans1=0
ans2=0
for i in range(n):
    if (i+2)%2==0:
        ans1+=B[i]
    else:
        ans2+=B[i]
print(int(ans1-ans2))

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

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

a=list(map(int,input().split()))
a=sorted(a,reverse=True)
Alice=[]
Bob=[]

for index,num in enumerate(a):
    if index%2 == 0:
        Alice.append(num)
    else:
        Bob.append(num)
        

ans=sum(Alice)-sum(Bob)

print(ans)

Solution (Python):
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        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)


if __name__ == '__main__':
    AtCoder().main()