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)

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

print(alice - bob)

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)
    else:
        bob += max(A)
    A.remove(max(A))
    
print(alice - bob)

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

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

Solution (Python):
def solve():
    a = read()
    result = think(a)
    write(result)


def read():
    n = read_int(1)[0]
    return read_int(n)


def read_int(n):
    return list(map(int, read_line().split()[:n]))


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a):
    local_a = list(a)
    a.sort(reverse=True)
    return sum(a[::2]) - sum(a[1::2])


def write(result):
    print(result)


if __name__ == '__main__':
    solve()

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

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

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a_total, b_total = 0,0
for k in range(N):
    m = max(a)
    if k%2==0:
        a_total += m
    else:
        b_total += m
    a.remove(max(a))
print(a_total-b_total)

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())
lis = [int(i) for i in input().split()]
alice = 0
bob =0


for i in range(n):
  curmax = max(lis)
  lis.remove(curmax)
  if i%2 == 0:
    alice += curmax
  else:
    bob += curmax
    
print(alice-bob)

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

Alice = 0
Bob = 0
for i, v in enumerate(A[::-1]):
  if i % 2 == 0:
    Alice += v
  else:
    Bob += v
print(Alice - Bob)

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

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

diff = 0

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

print(diff)

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

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

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

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

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

Solution (Python):

n = int(input())
A = [int(el) for el in input().split(' ')]

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

Solution (Python):
import numpy as np
N = int(input())
number_list = list(map(int,input().split()))
Alice_sum = 0
Bob_sum = 0
for i in range(N):
    if(i%2==0):
        Alice_sum += max(number_list)
        number_list.remove(max(number_list))
    else:
        Bob_sum += max(number_list)
        number_list.remove(max(number_list))
print(Alice_sum-Bob_sum)

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

a = sum(cards[0::2])
b = sum(cards[1::2])

print(a - b)

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

alice = 0
bob = 0

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

print(alice - bob)

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

alice = 0
bob = 0

for i in range(1,len(a)+1):
    if i % 2 != 0:
        alice += a.pop(a.index(max(a)))
    else:
        bob += a.pop(a.index(max(a)))

print(alice - bob)

Solution (Python):
CARD_NUM = int(input())
RAW_CARDS = input().split(' ')

card_array = [int(raw_card) for raw_card in RAW_CARDS]
card_array.sort(reverse=True)

alice_cards = list()
bob_cards = list()

is_alice = True

for card in card_array:
    if is_alice:
        alice_cards.append(card)
    else:
        bob_cards.append(card)
    is_alice = not is_alice

print(sum(alice_cards) - sum(bob_cards))

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

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

A = sorted(A, reverse=True)

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

print(alice - bob)

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

Solution (Python):

def main():
    n = int(input()) 
    a = list(map(int,input().split()))
    a.sort()
    o , e = 0 , 0 
    for i in range(n):
        if i % 2 == 0 :
            e += a[i] 
        else:
            o += a[i]
    print(abs(e-o))
main()

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

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

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

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

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

a.sort()
a.reverse()

sa = 0
sb = 0

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

print(sa-sb)

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

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

alicep=0
bobp=0

for i in range(n):
	if i%2 == 0:
		alicep += max(cardpoints)
		cardpoints.remove(max(cardpoints))
	else:
		bobp += max(cardpoints)
		cardpoints.remove(max(cardpoints))

print(alicep-bobp)

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

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

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

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

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

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(N):
	if i % 2 == 0:
		Alice += A[i]
	else:
		Bob += A[i]

print(Alice - Bob)

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

print(a-b)

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

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

print(alice-bob)

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

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

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

Solution (Python):
N=int(input())
a=list(map(int, input().split()))
a.sort()
A=0
B=0
is_A=True
while len(a)>0:
  if is_A:
    A+=a.pop()
  else:
    B+=a.pop()
  is_A = not is_A
print(A-B)

Solution (Python):


n = int(input())

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

a,b = 0,0

for i in range(n):
    if i%2==0:
        a += max(card)
        card.pop(card.index(max(card)))
    else:
        b += max(card)
        card.pop(card.index(max(card)))
        
    
print(a-b)

Solution (Python):
N = int(input())
kList = list(map(int, input().split()))
aTotal = 0
bTotal = 0
kList.sort(reverse=True)

for i in range(N):
    if i % 2 == 0:
        aTotal += kList[i]
    else:
        bTotal += kList[i]

print(aTotal - bTotal)

Solution (Python):
import math

n = int(input())



ls = list(map(int,input().split(" ")))







ls.sort(reverse=True)
print(sum(ls[0::2]) - sum(ls[1::2]))

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

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

n = int(input())
list = [int(i) for i in input().split()]

d = bSort(list)


A = 0
B = 0

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

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(key=lambda x: -x)
print(sum(A[0::2])-sum(A[1::2]))

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

As = sorted(A,reverse = True)
count = 0
for i in range(N):
  if i % 2 == 0:
    count += As[i]
  else:
    count -= As[i]
print(count)

Solution (Python):
N = int(input())
card = [int(i) for i in input().split()]
card = sorted(card,reverse = True)
ans = 0
for i in range(N):
  if i % 2 == 0:
    ans += card[i]
  else:
    ans -= card[i]
  
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):
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):
import numpy as np

n = int(input())

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

arr.sort()

a = 0
b = 0

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

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

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

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

for i, card in enumerate(cards):
  if i%2 == 0:
    d += card
  else:
    d -= card
print(d)

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

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

nums.sort(reverse=True)
print(sum(nums[0::2]) - sum(nums[1::2]))

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    n, a = IR(2)
    n %= 500
    if a >= n:
        print("Yes")
    else:
        print("No")
    return


def B():
    n = II()
    a = LI()
    a.sort(reverse=True)
    op = 0
    ans = 0
    for ai in a:
        ans += -ai * op or ai
        op ^= 1
    print(ans)
    return


def C():
    return


def D():
    return


if __name__ == '__main__':
    B()

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 = alice + a[i]
	else:
		bob = bob + a[i]
print(alice - bob)

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

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

alice = 0
bob = 0
ab = False
for i in l:
  if ab == False:
    alice += i
    ab = True
  else:
    bob += i
    ab = False
    
print(alice - bob)

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

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

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


sum_A = 0
sum_B = 0

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

ans = sum_A - sum_B

print(ans)

Solution (Python):


n = int(input())

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

a.sort(reverse = True)



al = sum([a[i] for i in range(0,n,2)])
bb = sum([a[i] for i in range(1,n,2)])

print(al-bb)

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)

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

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

alice = []
bob = []
sorted_cards = sorted(a, reverse=True)

for i, v in enumerate(sorted_cards):
    if i % 2 == 0:
        alice.append(v)
    else:
        bob.append(v)

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

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

if N%2 == 0:
    for i in range(N//2):
        a.append(max(A))
        A.remove(max(A))
        b.append(max(A))
        A.remove(max(A))       
else:
    for i in range(N//2):
        a.append(max(A))
        A.remove(max(A))
        b.append(max(A))
        A.remove(max(A))   
    a.append(max(A))

print(sum(a) - sum(b))

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

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

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

alice = 0
bob = 0
count = 1
while(count <= n):
    alice += max(a)
    index = a.index(max(a))
    del a[index]
    count += 1
    if(len(a) > 0):
        bob += max(a)
        index = a.index(max(a))
        del a[index]
        count += 1
    
print(alice - bob)

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

alice = list()
bob   = list()

for i in range(int(len(a_list)+1/2)):
	try:
		alice.append(max(a_list))
		a_list.remove(max(a_list))
		bob.append(max(a_list))
		a_list.remove(max(a_list))
	except ValueError:
		break

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

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

Solution (Python):
data = input().split()
N = int(data[0])
Ai = input().split()
ai =[]
for i in range(N):
    ai.append(int(Ai[i]))

ai.sort()
alice = 0
bob = 0
for i in range(1,N+1):
    if i%2 != 0:
        alice += ai.pop()
    else:
        bob += ai.pop()
print(alice - bob)

Solution (Python):
n = int(input())
ls = sorted(list(map(int, input().split())))
Alice = 0
Bob = 0

while len(ls) != 0: 
    Alice += ls.pop()
    if len(ls) == 0:
        break
    Bob += ls.pop()
print(Alice - Bob)

Solution (Python):
N = int(input())
a = [int(i) for i in input().split()]
a_sorted = sorted(a,reverse=True)
diff = 0
for i in range(int(N/2)):
       diff +=  a_sorted[2*i] - a_sorted[2*i + 1]
if(N%2 != 0):
       diff += a_sorted[N-1]
print(diff)

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

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

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

Solution (Python):
import copy

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

    p1_total = 0
    p2_total = 0
    for i in range(N):
        if i % 2 == 0:
            tmp = max(A)
            p1_total += tmp
            del A[A.index(tmp)]
        else:
            tmp = max(A)
            p2_total += tmp
            del A[A.index(tmp)]

    print(p1_total - p2_total)

if __name__ == '__main__':
    main()

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

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

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

x=0
y=0
for i in range(len(li)):
    for j in range(len(li)-1):
        if li[j]<li[j+1]:
            a=li[j]
            li[j]=li[j+1]
            li[j+1]=a


for k in range(len(li)):
    if k%2==0:
        x=x+li[k]
    else:
        y=y+li[k]

print(x-y)

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

Solution (Python):



N = int(input())
a = list(map(int, input().split()))
a.sort()
Alice = 0
Bob = 0

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

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

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

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())
a=[]
a=list(map(int,input().split()))
a.sort()
a.reverse()
alice=[]
bob=[]
for i in range (0,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 = list(map(int, input().split()))

a_sorted = sorted(a_list, reverse=True)
alice = sum(a_sorted[0::2])
bob = sum(a_sorted[1::2])

print(alice - bob)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
alice = 0
bob = 0
count = 1
for c in a:
    if count%2==1:
        alice += c
    else:
        bob += c
    count +=1
print(alice-bob)

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

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):
size = int(input())
nums = list(map(int, input().split()))
nums.sort()
nums.reverse()

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

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

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

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

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

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

Solution (Python):


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

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

ans = sum(alice) - sum(bob)

print(ans)

Solution (Python):
N = int(input())
cards = list(map(int, input().split()))
A = 0
B = 0
while len(cards) > 0:
  A += max(cards)
  cards.pop(cards.index(max(cards)))
  if len(cards) > 0:
    B += max(cards)
    cards.pop(cards.index(max(cards)))
print(A - B)

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

a_sum=0
b_sum=0
for i in range(n):
    cnt=0
    max_a=0
    for i in range(n):
        if (a[i]>=max_a):
            max_a=a[i]
            cnt=i
    a_sum = a_sum+a[cnt]
    
    a[cnt]=0
    cnt=0
    max_a=0
    for i in range(n):
        if (a[i]>=max_a):
            max_a=a[i]
            cnt=i
    b_sum = b_sum+a[cnt]
    
    a[cnt]=0
print(a_sum-b_sum)

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

Solution (Python):
def cardGameForTwo():
	N = int(input())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	diffPoint = 0 
	for index in range(0, N):
		if index % 2 == 0:
			diffPoint += a[index]
		else:
			diffPoint -= a[index]
	print(diffPoint)

cardGameForTwo()

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

print(sum(b)-sum(c))

Solution (Python):
def main():
	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)


if __name__ == '__main__':
	main()

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

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

Solution (Python):
n = int(input())
var = list(map(int, input().split()))
var_max = 0
alice = 0
bob = 0
for y in range(n):
    var_max = 0
    for x in var:
        if(var_max <= x):
            var_max = x
    var.remove(var_max)
    if(y % 2 == 0):
        alice += var_max
    else:
        bob += var_max
print(alice - bob)

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

Solution (Python):
N = int(input())
line = list(map(int, input().split()))
line.sort(reverse=True)
ans = 0
i = 0
while line:
    p = line.pop(0)
    if i % 2 == 0:
        ans += p
    else:
        ans -= p
    i += 1

print(ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
al, bo = [], []
for i in range(n):
	if i % 2 == 0:
		al.append(max(a))
		a.remove(max(a))
	else:
		bo.append(max(a))
		a.remove(max(a))
print(sum(al)-sum(bo))

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
al, bo = [], []
for i in range(n):
	if i % 2 == 0:
		al.append(max(a))
		a.remove(max(a))
	elif i % 2 == 1:
		bo.append(max(a))
		a.remove(max(a))
print(sum(al)-sum(bo))

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

dif = 0
sgn = '+'
for a in A:
    if sgn == '+':
        sgn = '-'
        dif += a
    else:
        sgn = '+'
        dif -= a

print(dif)

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
count = 0

a.sort(reverse = True)

for i in a:
    if count%2 == 0:
        alice += i
    else:
        bob += i
    count += 1

print(alice - bob)

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

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

for i in range(0,n,2):
    Alice.append(a[i])
    if i!=n-1:
        Bob.append(a[i+1])
    
d=sum(Alice)-sum(Bob)
print(d)

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

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

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

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

allis = 0
bob = 0

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

print(allis-bob)

Solution (Python):


n = int(input())

tmp = input().split()

hoge = list(map(lambda a: int(a), tmp))
hoge.sort()
hoge.reverse()

sum_al=0
sum_bo=0
for i,j in enumerate(hoge):
	if (i%2 == 0):
		sum_al+=j
	else:
		sum_bo+=j
print(sum_al-sum_bo)

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

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

    a_list = sorted(a_list, reverse=True)

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

Solution (Python):
n = int(input())
lst = [int(i) for i in input().split()]
lst.sort()
lst = lst[::-1]
sum_a = 0
sum_b = 0
for i in range(n):
    if i%2==0:
        sum_a += lst[i]
    else:
        sum_b += lst[i]
print(sum_a - sum_b)

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

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

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

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

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

Solution (Python):
import numpy as np

point_A = 0

point_B = 0
N = int(input())
A = np.array([int(i) for i in input().split()])
A = np.sort(A)
for j in range(N):
    if j % 2 == 0:
        point_A += A[N - 1 - j]
    else:
        point_B += A[N - 1 - j]
print("{}".format(point_A - point_B))

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

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

for i in range(n):
    for j in range(n):
        if a[i] < a[j]:
            work = a[i]
            a[i] = a[j]
            a[j] = work

s1 = 0
s2 = 0

for i in range(0,n,2):
    s1 += a[i]

for i in range(1,n,2):
    s2 += a[i]

output = s2-s1

if output < 0:
    output *= -1

print(output)

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

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

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

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

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


alice=[]
bob=[]

for i in range(n):
    if i%2==0:
        alice.append(nums[i])

    else:
        bob.append(nums[i])

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

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

A, B = 0, 0

a.sort()
a.reverse()
for i, j in enumerate(a):
    if i % 2 == 0:
        A += j
    else:
        B += j
        
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):
length = int(input())
cards = list(map(int,input().split()))
sorted_cards = sorted(cards, reverse=True)
Alice_sum = sum(sorted_cards[0::2])
Bob_sum = sum(sorted_cards[1::2])
print(Alice_sum-Bob_sum)

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

Solution (Python):
N = int(input())
a = [int(aa) for aa in input().split()]
a.sort(reverse = True)
A = []
B = []
while len(a) > 0:
  A.append(a[0])
  a.pop(0)
  if len(a) == 0:
    break
  B.append(a[0])
  a.pop(0)
ans = sum(A) - sum(B)
print(ans)