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 = [0]*N
a = list(map(int, input().split()))
a.sort()
a_sort = [i for i in a[::-1]]
Alice = [i for i in a_sort[::2]]
Bob = [i for i in a_sort[1::2]]
print(sum(Alice)-sum(Bob))

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

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

print(ans)

Solution (Python):
n = int(raw_input())
inpt = map(int, raw_input().split())
inpt.sort()
inpt.reverse()

ans = 0

for i in range(0, n):
	ans = ans + inpt[i] * (1 - 2 * (i%2))

print ans

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)
A = 0
for i in range(0, N, 2):
  A += a[i]
print(A * 2 - sum(a))

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

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

card.sort(reverse=True)

Alice = [card[i] for i in range(0, N, 2)]
Bob = [card[i] for i in range(1, N, 2)]

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

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

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

Alice = 0
Bob = 0

for i in range(len(card)):
    if i % 2 == 0:
        Alice += max(card)
    else:
        Bob += max(card)
    del card[card.index(max(card))]

print(str(Alice - Bob))

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

a.sort(reverse=True)                
alice = sum([i for i in a[0::2]])   
bob = sum([i for i in a[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.pop(0)
    else:
        bob += a.pop(0)
print(alice-bob)

Solution (Python):
if __name__ == '__main__':
    _ = input()
    n_list = [int(n) for n in input().split()]
    
    p_alice = 0
    p_bob = 0
    i = 0
    for n in sorted(n_list, reverse=True):
        if i%2 == 0:
            p_alice += n
        else:
            p_bob += n
        i += 1

    print(p_alice - p_bob)

Solution (Python):


n = int(input())
nums = [int(x) for x in input().split()]
alice = 0
bob = 0
while nums != []:
    alice += max(nums)
    nums.remove(max(nums))
    if nums != []:
        bob += max(nums)
        nums.remove(max(nums))
print(alice - bob)

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

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

Solution (Python):
N=int(input())
A=input()
allcards=A.split()
for i in range (len(allcards)):
    allcards[i]=int(allcards[i])
allcards.sort()
alice=[]
bob=[]
alicet=True
bobt=False

for a in allcards:
    if alicet == True :
        alice.append(a)
        alicet=False
        bobt=True
    elif bobt == True:
        bob.append(a)
        bobt=False
        alicet=True

alicesum=sum(alice)
bobsum=sum(bob)

if alicesum - bobsum > 0 :
    print(alicesum - bobsum)
else :
    print(bobsum - alicesum)

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

Solution (Python):


if __name__ == "__main__":
    N = int(input())
    As = list(map(int, input().split()))
    As.sort(reverse=True)
    alice = 0
    bob   = 0
    for i in range(len(As)):
        if i%2 == 0:
            alice += As[i]
        else:
            bob   += As[i]
    print(alice - bob)

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

a.sort(reverse=True)

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

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

for i in range(0, len(arr)-1):
    for j in range(i+1, len(arr)):
        if arr[i]<arr[j]:
            buf = arr[i]
            arr[i] = arr[j]
            arr[j] = buf

sa = 0
sb = 0
for i in range(0, len(arr)):
    if i % 2 == 0:
        sa += arr[i]
    else:
        sb += arr[i]
print(sa - sb)

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

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

Solution (Python):
import math
import sys

def getinputdata():

    
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()


n = int(arr_data[0][0])
arr = arr_data[1]
arr2=list(map(int, arr))
arr2.sort(reverse=True)


mysum1=0
mysum2=0

flg=True

for v in arr2:
    
    if flg:
        
        flg=False
        mysum1+=v
        
    else:
        
        flg=True
        mysum2+=v
        

print(mysum1-mysum2)

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

a_list.sort(reverse=True)

alice = 0
for a in a_list[::2]:
    alice += a

bob = 0
for b in a_list[1::2]:
    bob += b

print(alice - bob)

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

a.sort(reverse=True)

alice_score = 0
bob_score =0

for i,j in enumerate(a):
    if i % 2 == 0:
        alice_score += j
    else:
        bob_score += j

print(alice_score-bob_score)

Solution (Python):


n = int(input())
ai = list(map(int, input().split()))
assert len(ai) == n
ai = sorted(ai, reverse=True)

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

print(ali - bob)

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



a.sort(reverse = True)

alice, bob = 0, 0

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

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


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

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

    print(ans)

if __name__ == '__main__':
    main()

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())
l = list(map(int, input().split()))
l.sort(reverse=True)
print(sum([l[i] for i in range(0, len(l), 2)]) - sum([l[i] for i in range(1, len(l), 2)]))

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

print(ans)

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

Solution (Python):
n=int(input())
nums=list(map(int,input().split()))
nums.sort(reverse=True)
Alice_sum=0
Sum=sum(nums)

if n%2==0:
    for i in range(0,n,2):
        Alice_sum += nums[i]
    print(Alice_sum*2-Sum)
else:
    for i in range(0,n,2):
        Alice_sum += nums[i]
    print(Alice_sum*2-Sum)

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

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


a.sort(reverse=True)

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

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

Solution (Python):
import sys;
import numpy as np;
sys.stdin.readline()
a=np.sort(np.array(sys.stdin.readline()[:-1].split(),dtype=np.int32))[::-1]
if a.size%2:
 a=np.append(a,0)
a=np.reshape(a,(-1,2)).T
print(np.sum(a[0]-a[1]))

Solution (Python):
import sys;
import numpy as np;
sys.stdin.readline()
a=np.sort(np.array(sys.stdin.readline()[:-1].split(),dtype=np.int32))[::-1]
if a.size%2:
 a=np.append(a,0)
a=np.reshape(a,(-1, 2)).T
print(np.sum(a[0]-a[1]))

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(""))
data = input("")
a = data.split(" ")
ans = 0

for i in range(n):
    a[i] = int(a[i])
a.sort(reverse = True)

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

Solution (Python):
N = int(input())
x = [int(i) for i in input().split()]
x.sort()
x.reverse()
answer = 0
for j in range(len(x)):
 if j%2 == 0: answer+=x[j]
 else: answer-=x[j]
print(answer)

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 = int(input())
a = list(map(int, input().split()))
p = [0,0]

for i in range(n):
    p[i%2] += max(a)
    a.remove(max(a))
print(p[0]-p[1])

Solution (Python):
N = int(input())
a = [int(i) for i in input().split()]
a.sort(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 = map(int, input().split())

a = sorted(list(A), reverse=True)
print(sum(a[0::2]) - sum(a[1::2]))

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

Alice = 0
Bob = 0

for i in range(n):
    if i % 2 == 0:
        Alice += b[i]
    else:
        Bob += b[i]
c = Alice - Bob

print(c)

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

cnt = 0
plmn = 1
for i in a:
    cnt += plmn * i
    plmn *= -1

print(cnt)

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

Alice, Bob = 0, 0

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

print(Alice - Bob)

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

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

print(ret)

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n = ni()
a = na()
a = sorted(a, reverse=True)
ai = [i for i in range(0,n,2)]
bi = [i for i in range(1,n,2)]
alice = 0
bob = 0
for i in ai:
    alice += a[i]
for i in bi:
    bob += a[i]
print(alice-bob)

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

A = 0
B = 0
i = 0
while(True):
 A += a[i]
 i += 1
 if i==n: break
 B += a[i]
 i += 1
 if i==n: break

print(A-B)

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

A = 0
B = 0
while(True):
 mx = max(a)
 if mx == -1: break
 mx_idx = a.index(mx)
 a[mx_idx] = -1
 A += mx
 
 mx = max(a)
 if mx == -1: break
 mx_idx = a.index(mx)
 a[mx_idx] = -1
 B += mx

print(A-B)

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

cards.sort()

for i, x in enumerate(cards):
    if i%2 == 0:
        Alice.append(x)
    else:
        Bob.append(x)

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

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

l = list(sorted(l))

for i in range(1, N+1):
    if i%2 == 1:
        S+=l[N-i]
        
    else:
        S-=l[N-i]
        
            


print(S)

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

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

l.sort(reverse=True)

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):
import numpy as np

N = int(input())
As = input().split(' ')

na = np.array(As, np.int)

na = np.sort(na)[::-1]

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

print(a)

Solution (Python):
if __name__ == '__main__':
    n = int(input())
    a_list = sorted([int(a) for a in input().split()], reverse=True)

    alice_point = sum(a_list[::2])
    bob_point = sum(a_list[1::2])
    print(alice_point - bob_point)

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

Alice = 0
Bob = 0

if N%2 == 0:
    for n in range(int(N/2)):
        Alice += max(a)
        a.remove(max(a))
        Bob += max(a)
        a.remove(max(a))
else:
    for n in range(int((N-1)/2)):
        Alice += max(a)
        a.remove(max(a))
        Bob += max(a)
        a.remove(max(a))
    Alice += max(a)
print(Alice - Bob)

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

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

Solution (Python):
N = int(input())
a = [int(i) for i in input().split()]
a.sort()
a.reverse()
score = 0
for i in range(N):
    score = score + a[i]*(-1)**i
print(score)

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

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

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

a.sort()
a.reverse()

ans = 0
for i in range(n):
    ans += (-1)**i * a[i]
print(ans)

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

Solution (Python):
time=input()
lis=map(int, raw_input().split())

lis.sort()
lis.reverse()
A=0
B=0
ch=0
for i in lis:
    if ch==0:
        A+=i
        ch=1
    else:
        B+=i
        ch=0

print A-B

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

a_list_sort = a_list.sort(reverse=True)

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

Alice_score = sum(Alice)
Bob_score = sum(Bob)

dif = abs(Alice_score - Bob_score)
print(dif)

Solution (Python):

N = int(input())
ary = [int(x) for x in input().split(" ")]
ary.sort()
ary.reverse()

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

print(alice - bob)

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

Solution (Python):
N=int(input())
a = [int(i) for i in input().split()] 
a.sort(reverse=True)
p1=a[0:N:2]
p2=a[1:N:2]
sum1=0
sum2=0
for i in p1:
	sum1+=i
for i in p2:
	sum2+=i

print(sum1-sum2)

Solution (Python):
def solve(a_list):
  alice_sum = 0
  bob_sum = 0
  a_list.sort()
  while True:
    if a_list == []:
      break
    alice_sum += a_list.pop()
    if a_list == []:
      break
    bob_sum += a_list.pop()
  
  return alice_sum - bob_sum

def main():
  N = int(input())
  a_list = list(map(int, input().strip().split()))
  print(solve(a_list))

if __name__ == '__main__':
  main()

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

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

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

alice = []
bob = []
for i in range(1, n+1):
    val = max(card)
    del card[card.index(val)]
    if i % 2 == 1:
        alice.append(val)
    else:
        bob.append(val)

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

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

Solution (Python):


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

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

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

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

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

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

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

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

Solution (Python):
N = int(input())
card = [int(i) for i in input().split()]
card.sort()
Alice,Bob = 0,0

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

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

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

List.sort(reverse = True)
Alice = List[::2]
Bob = List[1::2]
print(sum(Alice) - sum(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())

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

if N%2 == 1:
    cards.append(0)

cards=sorted(cards)
ret=0
i=len(cards)-1

while i>=0:
    ret+=cards[i]-cards[i-1]
    i-=2

print(ret)

Solution (Python):
n = int(input())
alist = list(map(int, input().split()))
alist.sort(reverse=True)
p1 = []
p2 = []
for i in range(n):
    if i%2 == 0:
        p1.append(alist.pop(0))
    else:
        p2.append(alist.pop(0))

print(sum(p1)-sum(p2))

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

alist = sorted(alist, reverse=True)
black = sum(alist[::2])
white = sum(alist[1::2])

print(black - white)

Solution (Python):
import functools
_ = input()
A = [int(i) for i in input().split()]
score = 0
for i, a in enumerate(sorted(A, reverse=True)):
    score += a if i % 2 == 0 else -a
print(score)

Solution (Python):
N = int(input())
alist = input().split()
aint = list(map(int, alist))
aint = sorted(aint, reverse=True)
count = 1
alice = 0
bob = 0

for a in aint:
    if count % 2:
        alice += a
    else:
        bob += a
    count = count + 1
print(alice - bob)

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

n = sorted(n, reverse=True)

f= n[::2]
s = n[1::2]

for i in range(len(f)):
    Alice += int(f[i])
    
for j in range(len(s)):
    Bob += int(s[j])



print(int(Alice)-int(Bob))

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

a, b = 0, 0
f = 'a'
while(len(c) != 0):
    if f == 'a':
        a += c.pop()
        f = 'b'
    elif f == 'b':
        b += c.pop()
        f = 'a'
print(a - b)

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

alice = 0
bob = 0

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

print (alice - bob)

Solution (Python):
N = int(input())
a = sorted(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]

res = Alice - Bob

print(res)

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

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

Solution (Python):
n = int(input())
a = [int(x) for x in 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=[int(i) for i in input().split(" ")]
a.sort()
a.reverse()

delta=0
for i in range(N):
    delta+=((-1)**i)*a[i]
print(delta)

Solution (Python):

N = int(input())
a = list(map(int, input().split(" ")))
a.sort()
a.reverse()
x = [0, 0]
for i in range(N):
    x[i%2] = x[i%2] + a[i]

print(abs(x[0]-x[1]))

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

Solution (Python):
N = input()
l = [i for i in range(int(N))]
temp = input()
l = temp.split()
for j in range(int(N)):
    l[j] = int(l[j])
l = sorted(l)
l.reverse()
A = 0
B = 0
for i in range(len(l)):
    if i % 2 == 0:
        A += l[i]
    else:B += l[i]

re = A-B
print(re)

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

A.sort()
A.reverse()

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

Solution (Python):
n = int(input())
nlist = list(map(int, input().split()))
alice = 0
bob = 0
for i in range(n):
    if(i%2==0):
        alice = alice + max(nlist)
    else:
        bob = bob + max(nlist)
    nlist.remove(max(nlist))
print('{}'.format(alice-bob))

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

Solution (Python):


"""One line explanation of b.py.

More explanations of b.py."""

import sys

def read_input(fin):
    l0 = fin.readline()
    l1 = fin.readline()
    return sorted([int(c) for c in l1.strip().split(' ')], reverse=True)

def solve(data):
    result = 0
    sign = 1
    for d in data:
        result += d * sign
        sign = -sign
    return result

def main(argv):
    d = read_input(sys.stdin)
    sys.stdout.write('%d\n' % solve(d))
    

if __name__ == '__main__':
    main(sys.argv)

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

a.sort()
a.reverse()

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

import numpy as np

n = int(raw_input())

a = np.array(map(int, raw_input().split()))

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

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

print Alice - Bob

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

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

s=0
i=0

for i in range(N):

    s+=list1[i]*(-1)**i
    i+=1

print(s)

Solution (Python):


n=int(raw_input())
a=map(int,raw_input().split())
b=sorted(a,reverse=True)
al=0
bo=0
for i in xrange(n):
 if i%2==0:
  al+=b[i]
 else:
  bo+=b[i]
print al-bo

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

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 = a + max(l)
        l.remove(max(l))
    else:
        b = b + max(l)
        l.remove(max(l))
print (a-b)

Solution (Python):
N=int(input())
a=sorted(map(int,input().split()),reverse=True)
ans=sum(((-1)**i)*x for i,x in enumerate(a))
print(ans)

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

arr.sort()
arr.reverse()
A = sum(arr[0::2])
B = sum(arr[1::2])
print(A - B)

Solution (Python):

if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))
    count = 0
    alice = 0
    bob = 0
    while len(a) > 0:
        a.sort()
        if count%2:
            bob += a.pop()
        else:
            alice += a.pop()
        count += 1
    else:
        print(alice - bob)

Solution (Python):
N = int(input())
a_i = list(map(int, input().split(" ")))
 
x = []
y = []
 
if N%2==0:
    for j in range(int(N/2)):
        x.append(max(a_i))
        a_i.remove(max(a_i))
        y.append(max(a_i))
        a_i.remove(max(a_i))
 
else:
    for j in range(int((N/2)+1)):
        x.append(max(a_i))
        a_i.remove(max(a_i))
        if a_i == []:
            break
        y.append(max(a_i))
        a_i.remove(max(a_i))
 
X = sum(x)
Y = sum(y)
 
 
if X >= Y:
    print(X - Y)
 
else:
    print(Y - X)

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

x = []
y = []

if N%2==0:
    for j in range(int(N/2)):
        x.append(max(a_i))
        a_i.remove(max(a_i))
        y.append(max(a_i))
        a_i.remove(max(a_i))

else:
    for j in range(int((N/2)+1)):
        x.append(max(a_i))
        a_i.remove(max(a_i))
        if a_i == []:
            break
        y.append(max(a_i))
        a_i.remove(max(a_i))

X = sum(x)
Y = sum(y)


if X >= Y:
    print(X - Y)

else:
    print(Y - X)

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

l.sort()
l.reverse()

result = 0

for e in enumerate(l):
    result += e[1] if e[0] % 2 == 0 else -e[1]

print(result)

Solution (Python):
def main():
    N = int(input() )
    a = []
    a = [int(num) for num in input().split() ]
    
    a.sort(reverse = True )



    
    score_A = sum(a[0::2 ] )
    score_B = sum(a[1::2 ] )
    
    print(score_A - score_B)
    
if __name__=="__main__":
    main()

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

Solution (Python):


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

A_lis = sorted(A)
c = 1
score = 0

for i in range(N):
    n = A_lis.pop()
    if c%2 == 0:
        score -= n
    elif c%2 == 1:
        score += n
    c += 1

print(score)

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

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

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

A=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())
data = list(map(int, input().split(' ')))
data.sort(reverse = True)
score = 0
is_Alices_turn = True

for data in data:
    if is_Alices_turn:
        score += data
    else:
        score -= data
    is_Alices_turn = not is_Alices_turn

print(score)

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

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

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

Solution (Python):
n = input()
a = [int(i) for i in raw_input().split(" ")]
a.sort()
i = n - 1
x, y = 0, 0
k = 0
while i >= 0:
  if k == 0: x += a[i]
  else: y += a[i]
  i -= 1
  k = 1 - k
print x - y

Solution (Python):


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

AList.sort()
AList.reverse()

alice = 0
bob = 0

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

print(alice-bob)

Solution (Python):
def main():
    N = int(input().strip())
    A = [int(x) for x in input().strip().split()]
    A.sort(reverse=True)
    alice = sum(A[0::2])
    bob = sum(A[1::2])
    return alice - bob

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

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

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

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

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