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 = [int(i) for i 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_list = sorted(list(map(int, input().split())), reverse=True)
n_alice = sum(a_list[::2])
n_bob = sum(a_list[1::2])
print(n_alice - n_bob)

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

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

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

Solution (Python):
N=int(input())
l=sorted(map(int,input().split()))[::-1]
v=sum([l[i] for i in range(0,N,2)])-sum([l[i] for i in range(1,N,2)])
print(v)

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 = [int(m) for m in input().split(" ")]

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

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


for i in range(len(a_list)):
    if i % 2:
        bob += sorted(a_list, reverse=True)[i]
    else:
        alice += sorted(a_list, reverse=True)[i]

print(str(alice - bob))

Solution (Python):
n=int(input())
num=sorted(list(map(int,input().split())),reverse=True)
a=[]
b=[]
flag=True
for i in range(n):
  l=max(num)
  num.remove(l)
  if flag:
    a.append(l)
    flag=False
  else:
    b.append(l)
    flag=True
print(sum(a)-sum(b))

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

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

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

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

alice = []
bob = []
for na in range(int(n)):
    if na == 0 or na % 2 == 0:
        maxn = max(nums)
        alice.append(maxn)
        nums.remove(maxn)
    else:
        maxn = max(nums)
        bob.append(maxn)
        nums.remove(maxn)

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

Solution (Python):
input();
al=[int(i) for i in input().split()]
al.sort()
al = al[::-1]
print(sum(al[::2])-sum(al[1::2]))

Solution (Python):


def main():
    
    n = int(input())
    lists = list(map(int, input().split()))
    
    lists.sort()
    lists.reverse()

    
    alice_sum = 0
    bob_sum = 0

    for i in range(n):
        
        
        if i % 2 == 0:
            alice_sum += lists[i]
        else:
            bob_sum += lists[i]
    
    print('{}'.format(alice_sum - bob_sum))

if __name__ == '__main__':
    main()

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

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

a = list(map(int,input().split()))
b = sorted(a,reverse=True)
Alice =[]
Bob =[]
for i in range(N):
    if (i+1)%2 !=0:
        Alice.append(b[i])
    else:
        Bob.append(b[i])

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

Solution (Python):

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

if n %2 !=0:
    a.append(0)
    n = n+1
    
a.sort()
b = a[::-1]

c=0
d=0


k = 0
while k != n:
   c += b[k]
   d += b[k+1]
   k = k +2
print(c-d)

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):
_ = input()
num_list = list(map(lambda x: int(x), input().split(" ")))

num_list.sort()
num_list.reverse()

Alice = 0
Bob = 0
turn = True

while(True):
  if len(num_list) == 0:
    break
  
  if turn:
    Alice += num_list.pop(0)
  else:
    Bob += num_list.pop(0)
  turn = not turn
print(Alice - Bob)

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

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

Solution (Python):
N = int(input())
A = [int(a) for a in input().split()]
A.sort()
A.reverse()
d = 0
for a in A[::2]:
  d += a
for a in A[1::2]:
  d -= a
print(d)

Solution (Python):
code=int(input())
arr = list(map(int, input().split()))
sumone=0
for i in range(code):
    for j in range(i+1,code):
        if arr[i]<arr[j]:
            box=arr[j]
            arr[j]=arr[i]
            arr[i]=box
for i in range(code):
    if i%2==0:
        sumone+=arr[i]
    else:
        sumone-=arr[i]
print(sumone)

Solution (Python):
N = int(input())
a = input().split()
ans = 0
for i in range(0,N):
	for j in range(i,N):
		if int(a[i]) < int(a[j]):
			b = a[i]
			a[i] = a[j]
			a[j] = b
for i in range(0,N,2):
	ans += int(a[i])
for i in range(1,N,2):
	ans -= int(a[i])
print(ans)

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

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

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

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

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

list.sort(reverse=True);

A = 0;
B = 0;

for i in range(0,N,2):
	A += list[i]

for i in range(1,N,2):
	B += list[i]

print(A - B)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
alice = 0
bob = 0
A.sort()
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())
alist = list(map(int, input().split(" ")))
alist.sort()
alist.reverse()
score_a = sum(alist[::2])
score_b = sum(alist[1::2])
print(score_a - score_b)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
Alice = 0
Bob = 0
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):

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

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

    print(alice - bob)
    

if __name__ == '__main__':
    main()

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

Solution (Python):
import numpy as np

N = input()
A = input()

x = np.array(list(map(int,A.split( ))))
j = []
for i in range(len(x)):
    j = np.append(j,np.max(x))
    y = np.where(x == np.max(x))[0][0]
    x[y] = 0
print(int(np.sum(j[::2])-np.sum(j[1::2])))

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

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

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 = sorted(a, reverse=True)
al = a[::2]
bo = a[1::2]
print(sum(al) - sum(bo))

Solution (Python):
i = 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=input()
a= sorted([int(j) for j 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()
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=int(input())
a=list(map(int,input().split()))
a.sort()
print(sum(a[n-1::-2])-sum(a[n-2::-2]) if n!=1 else a[0])

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

a.sort()

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

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

Solution (Python):
N=int(raw_input())
a=map(int,raw_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(map(int,input().split()),reverse=True)
print(sum([a[i] * (-1)**i for i in range(N)]))

Solution (Python):


def first_pop(l):
    if (len(l) <= 0):
        return 0
    else:
        return l.pop(0)

if __name__ == '__main__':

    n = int(input())
    a = sorted(map(int, (input().split())), reverse=True)
    alice, bob = 0, 0
    while len(a) > 0:
        alice += first_pop(a)
        bob += first_pop(a)

    print(alice - bob)

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

Alice = 0
Bob = 0

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

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

cards = sorted(a, reverse=True)
alice = 0
bob = 0

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

print(alice - bob)

Solution (Python):
_ = input()
xs = sorted([int(x) for x in input().split()], reverse=True)
print(abs(sum(xs[::2]) - sum(xs[1::2])))

Solution (Python):
d = '2 7 4'
d = input()
d = input()
d = [int(i) for i in d.split()]
d.sort()
s1 = 0
s2 = 0
i = len(d)-1
while(i>=0):
    s1 = s1 + d[i]
    if((i-1)>=0):
        s2 = s2 + d[i-1]
    i = i-2
print(s1-s2)

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

s_A = 0
s_B = 0
for i in range(N):
    if i % 2 == 0:
        s_A += a[i]
    elif i % 2 == 1:
        s_B += a[i]

print(s_A - s_B)

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

s_A = 0
s_B = 0
for i in range(N):
    if i % 2 == 0:
        s_A += a[i]
    elif i % 2 == 1:
        s_B += a[i]

print(s_A - s_B)

Solution (Python):

"""
Created on Fri Jun 15 11:27:37 2018

@author: Yuya
"""

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

print(Alice-Bob)

Solution (Python):
N = int(input())
A = [int(a) for a in input().split()]
A.sort()
A.reverse()
s = 0
for n in range(N):
    if n % 2 ==0:
        s += A.pop(0)
    else:
        s -= A.pop(0)
print(s)

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

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

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

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

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

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

Solution (Python):
import numpy
import re
import math

def main():
	"""
	テストコード実行
	:return:
	"""
	n = int(input())
	a = sorted(list(map(int, re.split(" +", input()))), reverse=True)
	print(sum(a[::2]) - sum(a[1::2]))

if __name__ == '__main__':
	main()

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())
cards = sorted(list(map(int, input().split())), reverse=True)
A, B = 0, 0
for idx in range(N):
  if idx % 2 == 0:
    A += cards[idx]
  else:
    B += cards[idx]
print(A - B)

Solution (Python):
N = int(input())
numbers = list(map(int, input().split()))
Alice_point = 0
Bob_point = 0

numbers.sort(reverse=True)

while True:
    try:
        Alice_point += numbers[0]
        Bob_point += numbers[1]
        numbers.remove(numbers[0])
        numbers.remove(numbers[0])
    except IndexError:
        break

print(Alice_point - Bob_point)

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

Solution (Python):
N = int(input())
Li = list(map(int,input().split()))
Li = sorted(Li)
a = 0
b = 0
while True:
    a += Li.pop()
    if not Li:
        break
        
    b += Li.pop()
    if not Li:
        break

print(a - b)

Solution (Python):


cnt = int(input())
card_list = [int(i) for i in input().split()]


alice = 0
bob = 0


card_list.sort(reverse=True)

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

print(alice - bob)

Solution (Python):
def ret_max_index(n, list):
    i = 0
    tmp = 0
    max = 0
    for i in range(n):
        if(max < list[i]):
            tmp = i
            max = list[i]
    return tmp

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

j = 0
k = 0
alice = 0
bob = 0
max = 0
lis_elem = len(lis)

for j in range(N):
    lis_elem = len(lis)
    max = lis[ret_max_index(lis_elem, lis)]
    
    del lis[ret_max_index(lis_elem, lis)]
    if(j%2 == 0):
        alice = alice + max
    elif(j%2 == 1):
        bob = bob + max

print(alice - bob)

Solution (Python):
def main():
    num_ans = int(input())
    card_list = list(map(int, input().split()))
    card_list.sort()
    card_list.reverse()
    print(sum(card_list) - sum(card_list[1::2]) * 2)


if __name__ == '__main__':
    main()

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

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

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

card_list.sort(reverse = True)


Alice = 0
Bob = 0
for i, j in enumerate(card_list):
    if (i + 1) % 2 == 0:
        Bob += j
    else:
        Alice += j


diff = abs(Alice - Bob)
print(diff)

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

Solution (Python):
N = int(input())
A = sorted(list(int(i) for i in 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):
import numpy as np
_ = int(input())
arr = np.array(list(map(int, input().split())))

arr.sort()
alice = arr[::-1][::2].sum()
bob = arr[::-1][1::2].sum()
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):
if __name__ == '__main__':
    n = int(input())
    cardlist = list(map(int, input().split()))
    cardlist.sort()

    alice_s, bob_s = 0, 0
    while cardlist != []:
        alice_s += cardlist.pop()
        if cardlist == []:
            break
        bob_s += cardlist.pop()
    ans = alice_s - bob_s
    print(ans)

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

cards.sort()
cards.reverse()

Alice = 0
Bob = 0

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

print(Alice-Bob)

Solution (Python):
while True:
    N = int(input())
    b = input().split()
    a = [int(i) for i in b]
    if (N >= 1 and N <= 100):
        for i in a:
            if (i < 1 or i > 100):
                continue
    else:
        continue
    break
a.sort(reverse=True)

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

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

A_list = A.split(" ")
A_int_list = list(map(int,A_list))

A_int_list.sort()
A_int_list.reverse()

alice=0
bob=0

for i in range(0,len(A_int_list)):
	if(i%2==0):
		alice += int(A_int_list[i])
	else:
		bob += int(A_int_list[i])

print(alice-bob)

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

a.sort()
a.reverse()

alice = 0
bob = 0

a_num = len(a)

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

print(alice - bob)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
alice,bob=0,0
cnt=0
for x in range(n):
    global alice
    global bob
    if cnt<n:
        alice+=a[cnt]
        cnt+=1
    if cnt<n:
        bob+=a[cnt]
        cnt+=1
print(abs(alice-bob))

Solution (Python):
n=int(input())
lst=list(map(int,input().split()))
al=0
bo=0
while True:
    m=max(lst)
    al+=m
    lst.remove(m)
    if len(lst)==0:
        break
    m=max(lst)
    bo+=m
    lst.remove(m)
    if len(lst)==0:
        break
print(al-bo)

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

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

Solution (Python):
N = int(input(''))
nums = sorted(map(int, input('').split()), reverse=True)
fp = sum(nums[::2])
sp = sum(nums[1::2])
print(fp - sp)

Solution (Python):

N = int(input())

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

A.sort()
A.reverse()

Alice = 0
Bob = 0

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

Solution (Python):
N = int(input())
cards = list(map(int, input().split()))
A, B = 0, 0
while cards != []:
    A += cards.pop(max(zip(cards, range(len(cards))))[1])
    if cards == []:
        break
    B += cards.pop(max(zip(cards, range(len(cards))))[1])
print(A - B)

Solution (Python):
alice = 0
bob = 0
ignore= input()
cards = []
cards.extend(map(int,input().split()))
for i in sorted(cards,reverse=True)[0::2]:
    alice += i
for i in sorted(cards,reverse=True)[1::2]:
    bob += i
print(alice-bob)

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

Solution (Python):
n = int(raw_input())
l = map(int, raw_input().split())
l.sort()
l.reverse()
a = 0
b = 0
for i,j in enumerate(l):
  if i % 2 == 0:
    a += j
  else:
    b += j
print a - b

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

a = sorted(list(map(int, input().split(' '))), reverse=True)
for i in a[::2]: alice += i
for i in a[1::2]: bob += i

print(alice - bob)

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

for i in asrt[::2]: alice += i
for i in asrt[1::2]: bob += i
print(alice - bob)

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

print(ans)

Solution (Python):
N = int(input())
a_list = list(map(int, input().split()))
a_list.sort(reverse=True)
Alice = []
Bob = []
for idx, v in enumerate(a_list):
    if idx % 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 = sorted(a, 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)
i = 0
ans = 0

for num in a:
    if(i % 2 == 0):
        ans += num
    else:
        ans -= num
    i += 1

print(ans)

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

Solution (Python):
n, a, x, s = int(input()), sorted(list(map(int, input().split()))), 1, 0
while(a):
    s += x*a.pop()
    x *= -1
print(s)

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

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

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

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

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

Solution (Python):
N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
A_cards = []
B_cards = []
flag = 'A'
for card in A:
    if flag == 'A':
        flag = 'B'
        A_cards.append(card)
    elif flag == 'B':
        flag = 'A'
        B_cards.append(card)
print(sum(A_cards) - sum(B_cards))

Solution (Python):

n = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)

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

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

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


sorted_a_map = sorted(a_line_map, reverse=True)

diff_map = (num if i%2==0 else -num for i,num in enumerate(sorted_a_map))
print(sum(diff_map))

Solution (Python):
N = int(input())
lines = input().split(' ')
lines = [int(x) for x in lines]
a_list = sorted(lines)
A = 0
B = 0


while len(a_list) > 0:
	A += a_list.pop()
	if len(a_list) > 0:
		B += a_list.pop()

print(A - B)

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

sorted_a_map = sorted(a_line_map, reverse=True)
dif_gen = (-num if i%2==1 else num for i, num in enumerate(sorted_a_map))
print(sum(dif_gen))

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

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

sumA=0
sumB=0

for i in range(0,N,2):
    sumA+=list[i]
for j in range(1,N,2):
    sumB+=list[j]

print(sumA-sumB)

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

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

l = sorted(a, reverse=True)
Alice = sum(l[::2])
Bob = sum(l[1::2])


print(Alice - Bob)

Solution (Python):
from collections import deque

N = int(input())
a_list = sorted(list(map(int, input().split(' '))))

score_list = [0] * 2

available_cards = deque(a_list)

while len(available_cards) != 0:
    score_list[0] += available_cards.pop()
    try:
        score_list[1] += available_cards.pop()
    except:
        break

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

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

Solution (Python):
N = int(input())
a = [int(x) for x in input().split()]
a.sort()
a.reverse()
bob = 0
i = 0
while 2*i + 1 < len(a):
    a[2*i + 1] = -a[2*i + 1]
    i += 1

print(sum(a))

Solution (Python):
N = int(input())
lines = input().split(' ')
lines = [int(x) for x in lines]
a_list = sorted(lines)
A = 0
B = 0


while len(a_list) > 0:
	A += a_list.pop()
	if len(a_list) > 0:
		B += a_list.pop()

print(A - B)

Solution (Python):
input()
numbers = list(map(lambda x: int(x), input().split(" ")))
numbers.sort(reverse=True)
alice = 0
bob = 0
isAlice = True;
for number in numbers:
    if isAlice:
        alice += number
        isAlice = False
    else:
        bob += number
        isAlice = True

print(alice - bob)

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%2 == 0:
        al += a[i]
    else:
        bo += a[i]
print(al-bo)

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

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

Solution (Python):
N = int(input())
card = list(map(int,input().split()))
A = 0
B = 0
card.sort(reverse = True)
while True:
    A += card[0]
    card.pop(0)
    if not card:
        break
    B += card[0]
    card.pop(0)
    if not card:
        break
print(A - B)

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

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

def main():
    A.sort(reverse=True)
    alist = [x for i, x in enumerate(A) if i % 2 == 0]
    blist = [x for i, x in enumerate(A) if i % 2 != 0]
    print(sum(alist) - sum(blist))

if __name__ == "__main__":
    main()

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

Solution (Python):
n = raw_input()
a = sorted(map(int,raw_input().split()), reverse=True)
print sum(map(lambda x:x[1],filter(lambda (i,x): i%2==0, enumerate(a)))) - sum(map(lambda x: x[1], filter(lambda (i,x): i%2!=0, enumerate(a))))

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

Solution (Python):
def game(a, n):
    cards = sorted(a, reverse=True)
    alice = [cards[i] for i in range(n) if i % 2 == 0]
    bob = [cards[i] for i in range(n) if i % 2 != 0]
    return sum(alice) - sum(bob)


if __name__ == '__main__':
    n = int(input())
    a = map(int, input().split())
    print(game(a, n))

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

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

a.sort()
ali = 0
bob = 0

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

Solution (Python):
N = int(input())
a = list(int(i) for i in input().split())
a.sort(reverse = True)
A, B = 0, 0

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

Solution (Python):

N = int(input())
number_list = list(map(int, input().split()))
sort_number_list = sorted(number_list, reverse=True)
 
Alice = 0
Bob = 0
for i, x in enumerate(sort_number_list):
  i += 1
  if i % 2 != 0:
    Alice += x
  else:
    Bob += x

print("{}".format(Alice - Bob))

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

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

    sorted_cards = sorted(cards, reverse=True)

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

    print(Alice-Bob)


solve()

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

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

    a_sorted = sorted(a, reverse=True)

    alice = sum(a_sorted[::2])
    bob = sum(a_sorted[1::2])

    print(alice - bob)

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

alice = 0
bob = 0

for i in range(n):

    max_num = max(s)

    if i % 2 == 0:
        alice += max_num
    else:
        bob += max_num

    s.remove(max_num)

print(abs(alice - bob))

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

if n > 1:
    print(sum(cards[::2])-sum(cards[1::2]))
else:
    print(cards[0])

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"


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

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

    return alice - bob


def main():
    print(solve())


if __name__ == '__main__':
    main()

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

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

Solution (Python):
n=int(input())
card=list(map(int,input().split()))
card.sort()
result=0
while len(card)>0:
   result+=card.pop()
   if len(card)>0:
       result-=card.pop()
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 = input()
a = sorted(list(map(int, input().split())), reverse = True)
b = sum(a[::2]) - sum(a[1::2])
print(b)