Problem:
 Score: 200 points    Problem Statement  We have N cards. A number a_i is written on the i -th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.      Constraints   N is an integer between 1 and 100 (inclusive).  a_i \ (1 \leq i \leq N) is an integer between 1 and 100 (inclusive).         Input  Input is given from Standard Input in the following format:  N  a_1  a_2  a_3  ...  a_N       Output  Print Alice's score minus Bob's score when both players take the optimal strategy to maximize their scores.        Sample Input 1 2
3 1      Sample Output 1 2  First, Alice will take the card with 3 . Then, Bob will take the card with 1 .
The difference of their scores will be 3 - 1 = 2 .       Sample Input 2 3
2 7 4      Sample Output 2 5  First, Alice will take the card with 7 . Then, Bob will take the card with 4 . Lastly, Alice will take the card with 2 . The difference of their scores will be 7 - 4 + 2 = 5 . The difference of their scores will be 3 - 1 = 2 .       Sample Input 3 4
20 18 2 18      Sample Output 3 18

Solution (Python):
def solve(string):
    n, *a = map(int, string.split())
    a = sorted(a, reverse=True)
    return str(sum(a[::2]) - sum(a[1::2]))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

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

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

Alice = 0
Bob = 0

for i in range(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)
print(sum(a[0::2]) - sum(a[1::2]))

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a.sort()
Alice=0
Bob=0
for i in range(n):
  if len(a)>0:
    Alice+=a.pop()
  if len(a)>0:
    Bob+=a.pop()
print(Alice-Bob)

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

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
a=0
b=0
def max():
    m = 0
    j = 0
    for i in range(len(x)):
        if x[i]>m:
            m=x[i]
            j=i
    x.pop(j)
    return m
if n%2 == 0:
    i=0
    while i<n:
        a += max()
        b += max()
        i += 2
else:
    i=0
    while i<n-1:
        a += max()
        b += max()
        i += 2
    a+=max()
print(a-b)

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

score_a = 0
score_b = 0
for i in range(N):
    if i % 2 == 0:
        score_a += Ai[i]
    else:
        score_b += Ai[i]
print(score_a - score_b)

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

L.sort()
L.reverse()

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())
L = input().split()
for i in range(N):
  L[i]=int(L[i])

L.sort()
L.reverse()

A=0
B=0

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

print(A-B)

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

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

print(ans)

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

print(sum([a*(-1)**i for i, a in enumerate(A)]))

Solution (Python):
input()
ai = [int(i) for i in input().split(" ")]
ai.sort()
ai = tuple((j ,a) for j,a in enumerate(reversed(ai)))
alice=sum([ a for j,a in list(filter(lambda x: x[0]%2 == 0, ai))])
bob=sum([ a for j,a in list(filter(lambda x: x[0]%2 == 1, ai))])
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):
def main():
    N = int(input())
    an = sorted(list(map(int, input().split())), reverse=True)
    print(sum(an[i] for i in range(0, N, 2)) -
          sum(an[j] for j in range(1, N, 2)))


main()

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]

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

ans = Alice - Bob
print(ans)

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

alice = 0
bob = 0

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

print(ans)

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

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

A.sort(reverse=True)

ans = 0
for i in range(N):
    if i % 2 == 0:
        ans += A[i]
    if i % 2 == 1:
        ans -= A[i]

print(ans)

Solution (Python):


import itertools
import collections
import bisect

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

    a_sum = sum([A[a] for a in range(0, len(A), 2)])
    b_sum = sum([A[a] for a in range(1, len(A), 2)])
    print(a_sum - b_sum)


if __name__ == '__main__':
    main()

Solution (Python):
from sys import exit

N = int(input())
a = sorted([int(n) for n in input().split()], key=lambda x:-x)
ali = 0
bob = 0
for i in range(N):
    if i % 2 == 0:
        ali +=a[i]
    else:
        bob +=a[i]
print(ali-bob)




exit()

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

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

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

Solution (Python):

input();c=0
for a in sorted(map(int,input().split())):c=a-c
print(c)

Solution (Python):
n = int(input())
a = sorted((int(s) for s in input().split()), reverse=True)
ans = sum(v * (-1 if i & 1 else 1) for i, v in enumerate(a))
print(ans)

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

Solution (Python):

n = int(input())

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

Ai.sort(reverse = True)


ans = 0
for i in range(n):
    
    ans += Ai[i] * (1 if i%2== 0 else -1)
    
print(ans)

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

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

alice = []

bob = []

for i in range(n):
	alice.append(max(card))
	del card[card.index(max(card))]
	if card == []:
		break
	bob.append(max(card))
	del card[card.index(max(card))]
	if card == []:
		break
        
print(sum(alice) - sum(bob))

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

card.sort()
card.reverse()

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

print (a-b)

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

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

a.sort()

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

print(Alice - Bob)

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

countA = 0
countB = 0

card_list.sort()
card_list.reverse()


for i, x in enumerate(card_list):
    if i % 2 == 0:
        countA += x
    else :
        countB += x
        
print(countA - countB)

Solution (Python):
N = int(input())
lst = sorted([int(x) for x in input().split()], reverse=True)
ret = 0
for idx, x in enumerate(lst):
    if idx % 2 == 0:
        ret += x
    else:
        ret -= x
print(ret)

Solution (Python):
N = int(input())
lst = sorted([int(x) for x in input().split()], reverse=True)
a = sum([lst[x] for x in range(0, len(lst), 2)])
b = sum([lst[x] for x in range(1, len(lst), 2)])
print(a - b)

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

Solution (Python):
def card_game_for_two(N: int, A: list) -> int:
    sorted_A = sorted(A, key=lambda x: - x)
    alice = sum(a for i, a in enumerate(sorted_A) if i % 2 == 0)
    bob = sum(a for i, a in enumerate(sorted_A) if i % 2 == 1)
    return alice - bob


if __name__ == "__main__":
    N = int(input())
    A = map(int, input().split())
    ans = card_game_for_two(N, A)
    print(ans)

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

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
alice=[]
bob=[]
for i in range(len(a)):
    alice.append(max(a))
    a.remove(max(a))
    if len(a)==0:
        print(sum(alice)-sum(bob))
        break
    bob.append(max(a))
    a.remove(max(a))
    if len(a)==0:
        print(sum(alice)-sum(bob))
        break

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

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

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

Solution (Python):
n=int(input())
hoge=list(map(int,input().split()))
hoge.sort()
hoge.reverse()
flag="A"
alice=0
bob=0
for i in range(n):
  if(flag=="A"):
    alice+=hoge[i]
    flag="B"
  else:
    bob+=hoge[i]
    flag="A"

print(alice-bob)

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

l.sort(reverse=True)
Alice = sum(l[0::2])
Bob = sum(l[1::2])

print(Alice-Bob)

Solution (Python):
N = int(input())
a = input().split()
a_list = []

for i in range(N):
    a_list.append(int(a[i]))

a_list.sort(reverse=True)

alice = 0
bob = 0

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

print(alice - bob)

Solution (Python):
N = int(input())
li = list(map(int,input().split()))
Alice = []
Bob = []

li=sorted(li,reverse=True)
for i in range(N):
    if i%2 == 0:
        Alice.append(li[i])
    else:
        Bob.append(li[i])
print(sum(Alice)-sum(Bob))

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

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

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

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

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

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

a.sort(reverse=True)

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

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

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

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

Solution (Python):
N = int(input())
an = sorted(list(map(int,input().split())),reverse = True)
A = 0
B = 0
for num,i in enumerate(an):
    if num%2==0:
        A+=i
    else:
        B+=i
print(abs(A-B))

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

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

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

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

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a.sort()
a = a[::-1]
alice = 0
bob = 0
i = 0
while i < len(a):
    alice += a[i]
    i += 1
    if i >= len(a):
        break
    bob += a[i]
    i += 1
print(alice - bob)

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

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

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

num_list.sort()
num_list.reverse()

for i in range(N):
  if i==0:
    sum = num_list[0]
  elif i%2==0:
    sum = sum + num_list[i]
  else:
    sum = sum - num_list[i]

print(sum)

Solution (Python):
N = int(input())
A = input().split()
sum_Alice = 0
sum_Bob = 0

for i in range(N):
  A[i] = int(A[i])
A.sort()
A.reverse()

for i in range(N):
  if(i%2 == 0):
    sum_Alice += A[i]
  else:
    sum_Bob += A[i]
    
print(sum_Alice - sum_Bob)

Solution (Python):
N = input()
a = [ int(n) for n in input().split()]
a.sort(reverse=True)
A = B = 0
while len(a) > 0:
	A += a.pop(0)
	if len(a) < 1:
		break
	else:
		B += a.pop(0)
print(str(A-B))

Solution (Python):
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))
    A = sorted(A, key=lambda x: -x)
    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):
S = 0
N = int(input())
a = [int(i) for i in input().split()]
a.sort()
for i in range(N):
  S += a[::-1][i] * (-1) ** i
print(S)

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

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

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

print(ans)

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


if __name__ == "__main__":
    main()

Solution (Python):
num = int(input())
input_str_list = input().split()
input_list = []
for i in input_str_list:
	input_list.append(int(i))
input_list.sort(reverse=True)

A = 0
B = 0
A_list = input_list[::2]
B_list = input_list[1::2]
for i in A_list:
	A += i
for i in B_list:
	B += i
print(A-B)

Solution (Python):
def calc(al,bo,a):
  if len(al)-len(bo) != 0:
    bo.append(a)
  else :
    al.append(a)
  return al,bo
    
N=int(input())
a=input().split()
a=[int(k) for k in a]
a.sort()

alice = []
bob = []

while(N!=0):
  alice,bob = calc(alice,bob,a[N-1])
  N -= 1
  
print(sum(alice)-sum(bob))

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

a.sort(reverse = True)

su = 0

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

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

alice = 0
bob = 0

for i in range((len(a) + 1 )// 2) :
    alice += max(a)
    a.remove(max(a))
    if len(a) != 0 :
        bob += max(a)
        a.remove(max(a))
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):
from sys import stdin

n = int(stdin.readline().rstrip())
a = list(map(int, stdin.readline().rstrip().split()))
a.sort()
a.reverse()

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 = 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(" ")))
i=0
a=0
b=0

while len(l)!=0:
    if i%2==0:
        a+=max(l)
        l.remove(max(l))
    else:
        b+=max(l)
        l.remove(max(l))
    i+=1
print(a-b)

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

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

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

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

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

a.sort()    

alice =[]
bob = []

i = 0

while(len(a) > 0):
    if (i % 2 == 0):        
        alice.append(a.pop(0))
        i += 1
    else:
        bob.append(a.pop(0))
        i += 1

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

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

Solution (Python):

n = int(input())
a = [int(x) for x in input().split()]
alice = 0
bob = 0
for i, v in enumerate(sorted(a, reverse=True)):
    if (i % 2 == 0):
        alice += v
    else:
        bob += v
print(alice - bob)

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

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

Solution (Python):
import sys
readline = sys.stdin.readline
n = int(input())
a = list(map(int, readline().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(str(alice-bob))

Solution (Python):

"""
Created on Wed Feb 27 21:41:45 2019

@author: yuta
"""

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

def main(a):
        card = sorted(a,reverse = True)
        Alice = sum(card[::2])
        Bob = sum(card[1::2])
        print(Alice - Bob)

main(a)

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

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

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
Alice = []
Bob = []
while a != []:
    get = max(a)
    Alice.append(get)
    a.remove(get)
    if a != []:
        get = max(a)
        Bob.append(get)
        a.remove(get)
print(sum(Alice) - sum(Bob))

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

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

ans=[0, 0]
p = 0
for i in range(n) :
    ans[p] += A[i]
    p = (p+1) % 2

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

Solution (Python):
import numpy as np

n = int(input())
a = list(map(int, input().split()))
alice = 0
bob = 0
side = 0 
for game_time in range(n):
    max_card = max(a)
    max_index = a.index(max_card)
    del a[max_index]
    if side == 0:
        alice += max_card
        side = 1
    else:
        bob += max_card
        side = 0
print(alice-bob)

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

Solution (Python):
n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
Alice = 0
Bob = 0
tf = 0
for i in l:
    if tf == 0:
        Alice += i
        tf = 1
    else:
        Bob += i
        tf = 0
ans = Alice - Bob
print(ans)

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

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

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

Solution (Python):

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


player_a=[]
player_b=[]

for i in range(len(a)):
	if(i==0 or i%2==0):
		player_a.append(a[i])
	else:
		player_b.append(a[i])

sum_a=sum(player_a)
sum_b=sum(player_b)

ans=sum_a-sum_b

print(ans)

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

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

    
print(sum)

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

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

def Turn(AB, l):
    m = max(l)
    AB += m
    l.remove(m)

    return (AB, l)

Alice = 0
Bob = 0

while num_lis:
    Alice, num_lis = Turn(Alice, num_lis)
    
    if num_lis:
        Bob, num_lis = Turn(Bob, num_lis)
    
print(Alice - Bob)

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

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

Solution (Python):
n,*a=map(int,open(0).read().split())  
b=sorted(a)[::-1];print(sum(b[::2])-sum(b[1::2]))

Solution (Python):
n,*a=map(int,open(0).read().split());b=sorted(a,reverse=True)
c=len(b);print(sum(b[i]for i in range(0,c,2))-sum(b[i]for i in range(1,c,2)))

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

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

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

Solution (Python):
n = int(input())
A = list(map(int,input().split()))
A = sorted(A)
Alice_card = []
Bob_card = []
for i in range(n):
        if i%2 == 0:
                Alice_card.append(A[i])
        else:
                Bob_card.append(A[i])
Alice_total = sum(Alice_card)
Bob_total = sum(Bob_card)
print(abs(Alice_total - Bob_total))

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

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

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

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

print(alice-bob)

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

Solution (Python):
n = input()
num = [i for i in map(int,input().split(" "))]

num.sort(reverse=True)

A = 0
B = 0
t=0
for i in num:
    if t%2==0:
        A+=int(i)
    else:
        B+=int(i)
    t+=1
print(A-B)

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

sa=0
sb=0

a=sorted(a,reverse=True)

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

print(sa-sb)

Solution (Python):

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

print(abs(alice-bob))

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

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

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

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

A = lsn[0::2]
B = lsn[1::2]
print(sum(A)-sum(B))

Solution (Python):
int_n = int(input())
int_array = list(map(int, input().split()))

int_array.sort(reverse=True)

alice = int_array[::2]

bob = int_array[1::2]

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

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

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

Solution (Python):
n = int(input())
l = list(map(int,input().split()))
a = 0
b = 0
for i in range(n):
    if i%2==0:
        a+=max(l)
        del l[l.index(max(l))]
    else:
        b+=max(l)
        del l[l.index(max(l))]
print(a-b)

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

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)
dif = 0
for i, p in enumerate(a):
    if i%2 == 0:
        dif += p
    else:
        dif -= p
print(dif)

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

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

deck.sort(reverse=True)
for i, card in enumerate(deck):
    if i % 2 == 0:
        Alice += card
    else:
        Bob += card

print(Alice - Bob)

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

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

for i in range(len(deck)):
    if i % 2 == 0:
        Alice += deck.pop(deck.index(max(deck)))
    else:
        Bob += deck.pop(deck.index(max(deck)))

print(Alice - Bob)

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

Solution (Python):
""" AtCoder """

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

a.sort(reverse = True)
f = 1
ans = 0

for i in range(N):
    ans += a[i] * f
    f *= -1

print(ans)

Solution (Python):
from statistics import mean, median,variance,stdev
import sys
import math
import fractions

def j(q):
    if q==1: print("Three")
    else:print("Four")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())




n = ip()                              



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





a.sort(reverse=True)
s = 0
for i in range(1,len(a),2):
    a[i]*=-1
print(sum(a))

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

Solution (Python):
n = int(input())
a = sorted(list(map(int,input().split())))
a.reverse()
c = 0
d = 0
for i in range(0,len(a),2):
    c += a[i]
for j in range(1,len(a),2):
    d += a[j]
    
print(c-d)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
b = sorted(a)
b.reverse()
c = 0
d = 0
for i in range(0,len(a),2):
    c += b[i]
for j in range(1,len(a),2):
    d += b[j]
    
print(c-d)

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

Solution (Python):
N=int(input())
tuple=input()
list=tuple.split()
list_int=[int(i) for i in list]
list=sorted(list_int)
Alice_Score=0
Bob_Score=0
for num in list[-1::-2]:
    Alice_Score+=num
for num in list[-2::-2]:
    Bob_Score+=num
difference=Alice_Score-Bob_Score
print(difference)