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()
A.reverse()
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 = input().split()
a = [int(x) for x in a]

alice = 0
Bob = 0

for i in range(N):
    if i%2==0:
        alice += max(a)
        a.remove(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.sort()
Alice = sum(a_list[-1::-2])
Bob = sum(a_list[-2::-2])
result = Alice - Bob
print(result)

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

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

card_list.sort()
card_list.reverse()

Alice = 0
Bob = 0

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

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

a.sort(reverse=True)

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

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

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

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

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

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())
a = [int(x) for x in input().split()]
a.sort()
a.reverse()
score = 0
for ind,i in enumerate(a):
    if(ind%2==0):
        score+=i
    else:
        score-=i
print(score)

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

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

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

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

Solution (Python):
N=int(input())
n=[int(i) for i in input().split()]
list.sort(n,reverse=True)
Ali=0
Bob=0

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

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

alice_count = 0
bob_count = 0
for i in range(N//2):
  alice_count += max(a)
  a.pop(a.index(max(a)))
  bob_count += max(a)
  a.pop(a.index(max(a)))

if a:
  alice_count += a[0]
  
count = alice_count - bob_count

print(count)

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


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

a.sort(reverse=True)

print(sum(j for i,j in enumerate(a) if i%2==0) - sum(j for i,j in enumerate(a) if i%2==1))

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
c1 = 0
c2 = 0
for i in a[::2]:
    c1 += i
    a.remove(i)
c2 = sum(a)
print(c1 - c2)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
al = []
bo = []
for idx, card in enumerate(a):
    if idx % 2 == 0:
        al.append(card)
    else:
        bo.append(card)
print(sum(al) - sum(bo))

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

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

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

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

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

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 = 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())
aList = list(map(int, input().split()))
aList.sort(reverse = True)
point = [0, 0]
for i in range(N):
    point[i%2] += aList[i]
print(point[0] - point[1])

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

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

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

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

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)

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

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

m = sum([n for i, n in enumerate(a) if i%2 == 0])

print(2*m - sum(a))

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[::2])
bob = sum(a[1::2])

print(alice - bob)

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

card.sort()
card.reverse()

A=card[0::2]
B=card[1::2]

ans=sum(A)-sum(B)

print(ans)

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

a.sort(reverse=True)

alice = True
al = 0
bo = 0

for a_ in a:
    if alice:
        al += a_
    else:
        bo += a_
    alice = not alice

print(al - bo)

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

card.sort()
card.reverse()

A = card[0::2]
B = card[1::2]

x = sum(A) - sum(B)

print(x)

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

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

b = sorted(a, reverse=True) 



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

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

Solution (Python):
n=int(input())
L=[int(i) for i in input().split()]
print(2*sum(sorted(L)[::-2])-sum(L))

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

Solution (Python):
N = int(input())
Ai = input().split()
Ai = [int(n) for n in Ai]
Ai = sorted(Ai, reverse=True)
Alice = 0
Bob = 0
i = 0
while True:
  if i+1 <= N-1:
    Alice += Ai[i]
    Bob += Ai[i+1]
  if i == N-1:
    Alice += Ai[i]
  if i > N-1:
    break
  i = i + 2

print(Alice - Bob)

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

total=0

for i in range(len(a)):
    if i % 2 == 0 :
        total+=max(a)
        index=a.index(max(a))
        a[index]=0
    else:
        total-=max(a)
        index=a.index(max(a))
        a[index]=0

print(total)

Solution (Python):
N = int(input())
list_an = input().split()
list_an_int = [int(s) for s in list_an]

list_an_int.sort()
list_an_int.reverse()

Alice_counter = 0
Bob_counter = 0

counter = 0
for i in range(N):
    if counter % 2 == 0:
        Alice_counter += list_an_int[i]
    else:
        Bob_counter += list_an_int[i]
    counter += 1
print(Alice_counter - Bob_counter)

Solution (Python):
import sys
l1, l2 = [sys.stdin.readline().strip() for i in range(2)]
input_list = [int(i) for i in l2.split()]
input_list.sort(reverse=True)
odd_index = [j for i, j in enumerate(input_list) if i%2 != 0]
even_index = [j for i, j in enumerate(input_list) if i%2 == 0]
print(sum(even_index) - sum(odd_index))

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

print(ans)

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

result = 0
is_even = True
for x in a:
    result += x if is_even else -x
    is_even = not is_even
print(result)

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

for i, num in enumerate(sorted(a)[::-1]):
    if i%2 == 0:
        alice += num
    else:
        bob += num

print(alice - bob)

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

Solution (Python):

N =int(input())

A=list(map(int,input().split()))
A.sort(reverse=True)
Alice=0
Bob =0
for j,i in enumerate(A):
    if j %2==0:
        Alice+=i
    else:
        Bob+=i
print(Alice-Bob)

Solution (Python):
N = int(input())
numbers_list = sorted([int(num) for num in input().split()])
Alice_sum = sum([numbers_list[index] for index in range(N) if index % 2 == 0])
Bob_sum = sum([numbers_list[index] for index in range(N) if index % 2 != 0])
print(abs(Alice_sum - Bob_sum))

Solution (Python):
n=int(input())
a=sorted([int(i) for i in input().split()])
A=sum([a[i] for i in range(n) if i%2==0])
B=sum([a[i] for i in range(n) if i%2!=0])
print(abs(A-B))

Solution (Python):

input()

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

alice = bob = 0

while(len(numbers)):
	if len(numbers) == 1:
		alice += numbers.pop()
	else:
		alice += numbers.pop()
		bob += numbers.pop()

print(alice - bob)

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

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

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

print(Alice - Bob)

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

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

Alice = 0
Bob = 0

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

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

n_list.sort()
sorted_list = n_list[::-1]

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

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

total = 0

while nums:
    total += max(nums)
    nums.remove(max(nums))
    if nums:
        total -= max(nums)
        nums.remove(max(nums))

print(total)

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

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

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

print(S)

Solution (Python):
n=input()
a=map(int, raw_input().split())
a.sort()
al=bo=0
i=0
for aa in reversed(a):
    if i%2==0:al+=aa
    else:bo+=aa
    i+=1
print(al-bo)

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

c = 0
ad = 0
for i in range(n):
 if c == 0:
  ad += b[i]
  c = 1
 else:
  ad -= b[i]
  c = 0

print(ad)

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

alice = a[::2]
bob = a[1::2]

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

Solution (Python):
_,s=open(0);c=0
for a in sorted(map(int,s.split())):c=a-c
print(c)

Solution (Python):
n = int(input())
a = [ int(i) for i in input().split() ]
a = sorted(a)[::-1]
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())
cards = sorted(list(map(int, input().split())), reverse=True)

alice = cards[::2]
bob = cards[1::2]

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

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

Solution (Python):

N = int(input())
a = list(map(int, input().split()))
b = sorted(a)[::-1]
Alice = 0
Bob = 0
for i in range(len(b)):
	if i % 2 == 0:
		Alice = Alice + b[i]
	else:
		Bob = Bob + b[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):
n = int(raw_input())
a = map(int, raw_input().split())
a.sort(reverse=True)
count = 0
if n % 2 == 0:
	for i in range(n / 2):
		count += (a[2 *i] - a[2 * i + 1])
else:
	for i in range((n - 1) / 2):
			count += (a[2 * i] - a[2 * i + 1])
	count += a[n - 1]
print count

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

A = sorted(A, 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 = input()
a = map(int, input().split())

alice_score = 0
bob_score = 0
for index, i in enumerate(sorted(a, reverse=True)):
    if index % 2 == 0:
        alice_score += i
    else:
        bob_score += i
print(alice_score-bob_score)

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

Solution (Python):


N = int(input())
A =[int(j) for j in input().split()]

A.sort(reverse=True)
Alice =[]
Bob = []

for i in range(N):
    if i % 2 ==0:
        Alice.append(A[i])
    else:
        Bob.append(A[i])
print(sum(Alice) -sum(Bob))

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

print(alice-bob)

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

print(alice-bob)

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

alice = 0
bob = 0

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

print(alice - bob)

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 = input()
li2 = input().split()
li = []
for l in li2:
  li.append(int(l))
li.sort()
li.reverse()
t = 0
ans = 0
for i in li:
  if t % 2 == 0:
    ans += int(i)
  else:
    ans -= int(i)
  t += 1

print(ans)

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

As = sorted(map(int,input().split()),reverse=True)

alice = 0
bob = 0

for i in range(0,N,2):
    alice += As[i]
    if i < N - 1:
        bob += As[i + 1]

print(alice - bob)

Solution (Python):


N = int(input())
li_raw = input().split()
li = [int(j) for j in li_raw]

turn = 1
A = 0
B = 0

while li != []:
    max = 0
    for x in li:
        if x > max:
            max = x
    if turn == 1:
        A += max
    else:
        B += max
    li.remove(max)
    turn = -turn
print(A-B)

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

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

counter = 0

A.sort(reverse=True)
for n in range(N):
    counter += A[n]*(-1)**n

print(counter)

Solution (Python):
N = int(input())
cards = [int(i) for i in input().split()]
alice = 0
bob = 0
for i in range(N):
    if i % 2 == 0:
        alice += max(cards)
        cards.remove(max(cards))
    elif i % 2 == 1:
        bob += max(cards)
        cards.remove(max(cards))
print(alice - bob)

Solution (Python):


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

a.sort()
a.reverse()

alice = 0
bob = 0

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

print(alice-bob)

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

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

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

alice = 0
bob = 0

ai_s.sort(reverse=True)

while ai_s:
    alice += ai_s.pop(0)
    if ai_s:
        bob += ai_s.pop(0)

ans = alice - bob
print(ans)

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

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

Solution (Python):

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

alice_list = []
bob_list = []
sorted(a_list)

for i in range(len(a_list)):
    max_a = max(a_list)
    a_list.remove(max_a)

    if i % 2 == 0:
        alice_list.append(max_a)
    else:
        bob_list.append(max_a)

answer = sum(alice_list) - sum(bob_list)
print(answer)

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

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

for i in range(n):
  if i % 2 == 0:
    score_alice += cards[i]
  else:
    score_bob += cards[i]

print(score_alice - score_bob)

Solution (Python):
N = int(input())
card_list = input().rstrip().split()
card_list = [int(s) for s in card_list]
sort_card_list = sorted(card_list, reverse = True)
alice_point = 0
bob_point = 0

for i, x in enumerate(sort_card_list):
    if i%2 == 0:
        alice_point = alice_point + x
    else:
        bob_point = bob_point + x

print(alice_point-bob_point)

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

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

score_alice= 0
score_bob = 0

while True:
  alice_card = max(A)
  A.remove(alice_card)
  score_alice += alice_card
  
  if len(A) == 0:
    break

  bob_card = max(A)
  A.remove(bob_card)
  score_bob += bob_card
  
  if len(A) == 0:
    break

print(score_alice - score_bob)

Solution (Python):
n=int(input())
li=list(map(int,input().split()))
li.sort()
a=[]
b=[]
for i in range(n):
  if n%2==1:
    if i%2==0:
      a.append(li[i])
    else:
      b.append(li[i])
  else:
    if i%2==0:
      b.append(li[i])
    else:
      a.append(li[i])
print(sum(a)-sum(b))

Solution (Python):


N = int(input())
a = sorted([int(x) for x in 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 = sum([a[i] for i in range(0, N, 2)])
Bob = sum(a) - Alice
print(Alice - Bob)

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

a_list.sort()
a_list.reverse()

x = 0
y = 0
n = 0

for a in a_list:
  if n % 2 == 0:
    x = x + a
    n = n +1
  else:
    y = y + a
    n = n +1

sabun = x - y

print(sabun)

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

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

A = A + [0, 0, 0, 0, 0]
sum = 0
for i in range(N//2 + 2):
  sum = sum + A[i*2] - A[i*2 + 1]
  
print(sum)

Solution (Python):
n = int(input())
a = sorted([int(item) for item in 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_num = sum(a[::2])
bob_num   = sum(a[1::2])
print(alice_num - bob_num)

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


A = sorted(A, reverse=True)

alice = A[0::2]
bob = A[1::2]

ans = sum(alice) - sum(bob)
print(ans)

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

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

alice = sorted_cards[0::2]
bob = sorted_cards[1::2]

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

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

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

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

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

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

Solution (Python):


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

alice = 0
bob = 0
turn = "alice"

a.sort()
a.reverse()

for i in range(n):
    if turn == "alice":
        alice += a[i]
        turn = "bob"
    else:
        bob += a[i]
        turn = "alice"

print(alice-bob)

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

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

a.sort(reverse=True)
ans = 0
for i in range(N):
    if i % 2 == 0:
        ans += a[i]
    else:
        ans -= a[i]

print(ans)

Solution (Python):



import sys
import math


N = int(input())
An = list(map(int, sys.stdin.readline().rstrip().split()))
An = sorted(An, key=lambda x:-x)
print(sum(An[0::2]) - sum(An[1::2]))

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 = [int(i) for i in input().split()]
a.sort()
a.reverse()
ans = sum(a[0:len(a):2]) - sum(a[1:len(a):2])
print(ans)

Solution (Python):
N = int(input())
a_list = list(map(int, input().split())) 
a_list.sort(reverse=True)
Alice, Bob = 0, 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())
data = list(map(int,input().split()))
data.sort(reverse=True)
alice = 0
bob = 0
for i in range(len(data)):
    if i%2 == 0:
        alice += data[i]
    elif i%2 == 1:
        bob += data[i]
        
print(alice-bob)

Solution (Python):
def main():
    N = int(input())
    a_s = list(map(int,input().split()))
    a_s.sort()
    a_s.reverse()
    Alice,Bob = 0,0
    for i,a in enumerate(a_s):
        if i % 2 == 0:
            Alice += a
        else:
            Bob += a
            
    print(Alice-Bob)


if __name__ == '__main__':
    main()

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

Solution (Python):
n = int(input())
l = list(map(int, input().split()))
Alice, Bob = 0, 0
for turn in range(0, n-1):
    if len(l) != 0:
        Alice += max(l)
        l.remove(max(l))
    if len(l) != 0:
        Bob += max(l)
        l.remove(max(l))
print(Alice-Bob)

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

Alice = []
Bob = []

while 0 < len(a):
    Alice.append(a.pop(a.index(max(a))))
    if 0 < len(a):
        Bob.append(a.pop(a.index(max(a))))

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

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

Solution (Python):
import math
n = int(input())
a_list = sorted(list(map(int,input().split())),reverse=True)
alice = []
bob = []
for _ in range(math.ceil(len(a_list)/2)):
    alice.append(a_list.pop(0))
    if len(a_list) == 0:
        break
    bob.append(a_list.pop(0))
print(sum(alice)-sum(bob))

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

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

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

san = sorted(an, reverse=True)
alice = 0
bob = 0
turn_alice = True
for a in san:
    if turn_alice:
        alice += a
    else:
        bob += a
    turn_alice = not turn_alice

print(alice - bob)

Solution (Python):

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

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

print(Alice-Bob)

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

Solution (Python):
from sys import stdin
n = int(stdin.readline().rstrip())
al = [int(_) for _ in stdin.readline().rstrip().split()]
al.sort(reverse=True)
print(sum(al[::2])-sum(al[1::2]))

Solution (Python):
n=int(input())
alice=[]
bob=[]
l=list(map(int,input().split()))
while len(l)>0:
    alice.append(max(l))
    l.remove(max(l))
    if len(l)>0:
        bob.append(max(l))
        l.remove(max(l))

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

Solution (Python):

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

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

a = sorted(a, reverse=True)

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

print(alice - bob)

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

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

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

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
a=sorted(a,reverse=True)
sc=[0,0]
for i,ai in enumerate(a):
    sc[i%2]+=ai
print(sc[0]-sc[1])

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

alice = [card[i] for i in range(len(card)) if i % 2 == 0]
bob = [card[i] for i in range(len(card)) if i % 2 == 1]

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

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

gusaku()

Solution (Python):
import numpy as np
N = int(input())
a = np.array(input().split(), dtype=int)
a = np.sort(a)[::-1]
print(np.sum(a[0::2]) - np.sum(a[1::2]))