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):
a = int(input())
ar = list(map(int,input().split(" ")))
A = 0
B = 0
while True:
  A += max(ar)
  ar.remove(max(ar))
  if len(ar) == 0:
      break
  B += max(ar)
  ar.remove(max(ar))
  if len(ar) == 0:
      break
print(A - B)

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

xs = sorted(A, reverse=True)

result = sum(xs[0::2]) - sum(xs[1::2])

print(result)

Solution (Python):
N = int(input())
card_list = list(map(int,input().split()))
card_list.sort(reverse=True)
Alice_list = []
Bob_list = []

for i in range(N):
    if i%2 == 0:
        Alice_list.append(card_list[i])
    else:
        Bob_list.append(card_list[i])

print(sum(Alice_list)-sum(Bob_list))

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

a.sort()
a.reverse()

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

print(A-B)

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

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

Solution (Python):


if __name__ == "__main__":
    n = int(input())
    vals = list(map(int, input().split()))

    alice, bob = 0, 0

    for i in range(n//2):
        dum = max(vals)
        alice += dum
        del vals[vals.index(dum)]

        dum = max(vals)
        bob += dum
        del vals[vals.index(dum)]

    if vals:
        alice += vals[0]

    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]

print(alice - bob)

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

alice = 0
bob = 0

for i in range(n + 1):
    max_index = a.index(max(a))

    if i % 2 == 0:
        alice += max(a)

    else:
        bob += max(a)

    a[max_index] = 0

print(alice - bob)

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

for i in a:
	A_B += i * B 
	B *= -1
    
print(A_B)

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


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

A_B = 0
B = 1

for i in a:
	A_B += i * B 
	B *= -1
    
print(A_B)

Solution (Python):
N = int(input())
a = list( map( int, input().split()))
a = sorted(a)
a.reverse()
Alice_Bob = 0
Bob = 1

for i in a:
	Alice_Bob += i * Bob  
	Bob *= -1
    
print(Alice_Bob)

Solution (Python):
N = int(input())
a = list( map( int, input().split()))
a = sorted(a)
a.reverse()
Alice = 0
Bob = 0
a.append(0)
a.append(0)

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

Solution (Python):
N = input()
a = map(int, raw_input().split())
a.sort()
a.reverse()
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 != 0])
print alice - bob

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

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

Solution (Python):

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

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

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

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

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

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

Solution (Python):
N=int(input())
List=list(map(int,input().split()))
List.sort(key=lambda x:x)
n=0
Alice=0
Bob=0
while n<=N-1:
  if n%2==0:
    Alice+=List[N-1-n]
  else     :
    Bob+=List[N-1-n]
  n+=1
print(Alice-Bob)

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


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

print(alice-bob)

Solution (Python):
def card_game():
    n = int(input())
    a_li = [int(i) for i in input().split()]
    ans = 0
    turn_switch = True

    li = sorted(a_li, reverse=True)

    for i in li:
        if turn_switch:
            ans += i
            turn_switch = False
        else:
            ans -= i
            turn_switch = True

    return ans


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

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

card.sort(reverse = True)
for i in range(n):
    if i % 2 == 0:
        alice += card[i]
    else:
        bob += card[i]
print(alice - bob)

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()
c=0
for i in range(n-1,-1,-1):
    if (n-i)%2==1:
        c+=a[i]
    else:
        c-=a[i]
print(c)

Solution (Python):
n=int(input())
A=list(map(int,input().split()))
A.sort()
total=0
i=n-1
while(0<=i-1):
  total+=A[i]-A[i-1]
  i-=2
if(i==0):
  total+=A[0]
print(total)

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

A.sort(reverse=True)

Alice = sum([a for a in A[0::2]])
Bob = sum([a for a in A[1::2]])

print(Alice - Bob)

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

Solution (Python):
n = int(input())
alice = 0
bob = 0

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

a.sort()
a.reverse()

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

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

ys = reversed(sorted(xs))
answer = 0
for i, y in enumerate(ys):
    if i % 2 == 0:
        answer = answer + y
    else:
        answer = answer - y
print(answer)

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

ys = reversed(sorted(xs))
zs = [y if i % 2 == 0 else -y for i, y in enumerate(ys)]
print(sum(zs))

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

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

a.sort()
a.reverse()

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

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

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

a=sum(n[::2])
b=sum(n[1::2])
print(a-b)

Solution (Python):


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

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

Solution (Python):
N = int(input())
cardlist = input().split()
cardlist = [int(n) for n in cardlist]
cardlist_s = sorted(cardlist, reverse=True)

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

Solution (Python):

n = int(input());
a = list(map(int, input().split(' ')));
alice = [];
bob   = [];

for x in range(n):
    m = max(a);
    i = a.index(m);
    if ( x%2 == 0):
        alice.append( a.pop(i) );
    else:
        bob.append( a.pop(i) );

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

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

A.sort()
A.reverse()

AL=[A[i] for i in range(0,N,2)]
BO=[A[i] for i in range(1,N,2)]

print(sum(AL)-sum(BO))

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

ali = 0
bob = 0

a.sort(reverse=True)
for i, m in enumerate(a):
    if i % 2 == 0:
        ali += m
    else:
        bob += m

print(ali - bob)

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

ali = bob = 0
for i,a in enumerate(reversed(A)):
    if i%2:
        bob += a
    else:
        ali += a
print(ali - bob)

Solution (Python):
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
a = list(li())

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

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

print(a-b)

Solution (Python):


import math

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


a.sort()
a.reverse()

sumA = 0
sumB = 0


sumA = sum(a[0::2])

sumB = sum(a[1::2])
print(sumA-sumB)

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

Solution (Python):

n = int(input())
cl = [int(_) for _ in input().split()]

cl.sort(reverse=True)

alice = 0
bob = 0

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

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

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

a = list(reversed(sorted(a)))

ans = 0
flag = 1
for x in a:
  ans += x * flag
  flag *= -1

print(ans)

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

Solution (Python):
n = int(input())
a = 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 = [int(_) for _ in input().split()]
if n % 2:
    a.append(0)

a.sort()

alice = 0
bob = 0

while len(a) > 0:
    alice += a.pop()
    bob += a.pop()

print(str(alice-bob))

Solution (Python):
N = int(input())
nums = list(map(int, input().split()))
nums.sort(reverse=True)
cnt = 0
Alice = 0
Bob = 0
for n in nums:
    if cnt % 2 == 0:
        Alice += n
    else:
        Bob += n
    cnt += 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):
N=int(input())
l=list(map(int,input().split()))
l.sort(reverse=True)
print(sum(l[0::2])-sum(l[1::2]))

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

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

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

c = a[-2::-2]
d = a[-1::-2]

print(sum(d)-sum(c))

Solution (Python):
def answer(*inp):

    N = int(inp[0])
    cards = sorted([int(n) for n in inp[1].split()], reverse=True)

    alice = 0
    bob = 0

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

    print(alice - bob)


answer(input(), input())

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

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

a.sort()
a = a[::-1]
for i in range(n):
    c = c + ((-1)**(i%2))*a[i]

print(c)

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

R = sum([a if i % 2 == 0 else -1 * a for i, a in enumerate(A)])
print(R)

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

Solution (Python):
import numpy as np

n = int(input())
a = np.sort(np.array([int(i) for i in input().split()]))[::-1]

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

print(alice-bob)

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

p_a = sum(sorted(a, reverse = True)[::2])
p_b = sum(a) - p_a
print(p_a - p_b)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort()
a = a[::-1]
total = 0
for i,x in enumerate(a):
  total += x*(-1)**i
print(total)

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

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

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

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

a.sort(reverse=True)

ans = 0
for i in range(len(a)):
	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):
n = int(input())
a = list(map(int, input().split()))
ans = 0
a.sort(reverse=True)

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

print(ans)

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

alice = 0
bob = 0

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

print(alice - bob)

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

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

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

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

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

alice_score = sum(a_list[0::2])
bob_score = sum(a_list[1::2])

print(alice_score - bob_score)

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

listA.sort()
listA.reverse()

pointA=0
pointB=0
index=0
while index <n:
    if index%2 ==0:
        pointA+=listA[index]
    else:
        pointB+=listA[index]
    index+=1

print(pointA-pointB)

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

Solution (Python):
n = int(input())
list_a = list((map(int, input().split())))
list_a.sort()
list_alice = list_a[-1::-2]
if n == 1:
    list_bob = []
else:
    list_bob = list_a[-2::-2]
ans_alice = 0
ans_bob = 0
for number in list_alice:
    ans_alice += number
for number in list_bob:
    ans_bob += number
print(ans_alice - ans_bob)

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

Solution (Python):
N = int(input())
list = [int(i) for i in input().split()]
sortlist = sorted(list, reverse=True)
Alice = 0
Bob = 0

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

print(Alice - Bob)

Solution (Python):



n = int(input())


line = list(map(int,input().split()))
pointA = 0
pointB = 0

while len(line) > 0:
    pointA += max(line)
    line.remove(max(line))
    if len(line) == 0:
        break
    else:
        pointB += max(line)
        line.remove(max(line))

print(pointA-pointB)

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

arr.sort(reverse=True)

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
alice = 0
bob = 0
flag_alice = True
for num in a:
    if flag_alice:
        alice += num
        flag_alice = False
    else:
        bob += num
        flag_alice = True
print(alice - bob)

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

    Alice = 0
    Bob = 0
    j = 0

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

    print(Alice - Bob)

main()

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

A.sort()

x=sum(A[-1::-2])
y=sum(A[-2::-2])
print(x-y)

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

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

print(ans)

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

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

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
A = sorted(A)
Alice = []
Bob = []
for i in range(N) :
    if i % 2 == 0 :
        Alice.append(A[-1])
    else :
        Bob.append(A[-1])
    A.pop(-1)
print(sum(Alice)-sum(Bob))

Solution (Python):
N = int(input())
A = list(map(int,input().split(' ')))
ans = 0
for i in range(N):
    ans = ans + max(A) * (-1) ** i
    A.remove(max(A))
print(ans)

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

Solution (Python):
from sys import stdin

N = int(stdin.readline().rstrip())
lst = [int(x) for x in stdin.readline().rstrip().split()]
lst.sort()
lst.reverse()

Alice = 0
Bob = 0

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

print(Alice - Bob)

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

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

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

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

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

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

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

Solution (Python):


n = int(raw_input())

l = []
l = map(int, raw_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

a.sort(reverse=True)

cnt = 0

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

print(alice - bob)

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

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

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

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

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

print(alice - bob)

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

a.sort()
for i in range(N):
    if i % 2 == 0:
        alice += a.pop()
    else:
        bob += a.pop()

print(alice - bob)

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

Solution (Python):
n = int(input())
a = sorted(list(map(int,input().split())))
a.reverse()
Alice = []
Bob = []
for i,p in enumerate(a):
    if i % 2 == 0:
        Alice.append(p)
    else:
        Bob.append(p)
print (sum(Alice) - sum(Bob))

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

a.sort()
a = a[::-1]

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

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

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N = int(input())
aa = inpl()
aa.sort(reverse=True)

f = s = 0
for i in range(N):
	if i%2 == 0:
		f += aa[i]
	else:
		s += aa[i]

print(f-s)

Solution (Python):
n = int(input())
a = sorted(list(map(int,input().split())))
a.reverse()
Alice = []
Bob = []
for i,p in enumerate(a):
    if i % 2 == 0:
        Alice.append(p)
    else:
        Bob.append(p)
print (sum(Alice) - sum(Bob))

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
alice = 0
bob = 0
a.sort()
a.reverse()
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())
a_list = list(map(int, input().split()))
a_list = sorted(a_list, reverse=True)

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

print(alice_point - bob_point)

Solution (Python):
import numpy as np

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

alice_point = 0
bob_point = 0
for i in range(n):
    argmax_a = np.argmax(a_list)
    max_a = np.max(a_list)
    if i % 2 == 0: 
        alice_point += max_a
    else: 
        bob_point += max_a
    del a_list[argmax_a] 

print(alice_point - bob_point)

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

a.sort()
a.reverse()

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

print(total)

Solution (Python):
n = int(input())
num = list(map(int, input().split()))
sum1 = sum2 = 0
for i in range(n):
    if i % 2 == 0:
        x = max(num)
        a = num.index(x)
        sum1 += x
        del num[a]
    else:
        y = max(num)
        b = num.index(y)
        sum2 += y
        del num[b]

print(sum1 - sum2)

Solution (Python):
N = int(input())
a_list = [a for a in map(int, input().split())]
a_list.sort()
a_list.reverse()
alice = 0
bob = 0

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

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

sorted_ai = sorted(ai, reverse=True)

alice = 0
bob = 0

for index, x in enumerate(sorted_ai):
    if (index % 2 == 0):
        alice += x
    else:
        bob += x
        
print(alice - bob)

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

Solution (Python):

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

for i in range(N):
    if i%2 == 0:
        Amax += max(A)
        A.remove(max(A))
    else:
        Bmax += max(A)
        A.remove(max(A))

print(Amax - Bmax)

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

Arr.sort(reverse=True)

i = 0
ans = 0
for a in Arr:
  if i%2 == 0:
    ans += a
  else:
    ans -= a
  i += 1

print(ans)

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


from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


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

if __name__ == '__main__':
    main()

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

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


solve()

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

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

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

a = sorted(a, reverse=True)

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

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

scores.sort()
scores.reverse()
alice_flag = True
alice_score = 0
bob_score = 0

for score in scores:
    if alice_flag:
        alice_score += score
        alice_flag = False
    else:
        bob_score += score
        alice_flag = True

print(alice_score - bob_score)

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

a.sort(reverse=True)

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

print(Alice-Bob)

Solution (Python):
n=int(input())
l=[int(i) for i in input().split()]
ans=sum(l)
l.sort()
for i in range(-2,-n-1,-2):
    ans-=l[i]*2
print(ans)

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

A=[]
B=[]
while len(a)>0:
    A.append(max(a))
    a.remove(max(a))
    if len(a)>0:
        B.append(max(a))
        a.remove(max(a))
print(sum(A)-sum(B))

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

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

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

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

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

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

A_point = sum([a for i, a in enumerate(a_list) if i % 2 == 0])
B_point = sum([a for i, a in enumerate(a_list) if i % 2 == 1])

print(A_point - B_point)