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=map(int,input().split())
a=sorted(a)[::-1]
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):
def main():
    N = int(input())
    a = [int(x) for x in input().split()]
    apoints = 0
    bpoints = 0
    for i in range(N):
        if i%2 == 0:
            apoints += max(a)
        else:
            bpoints += max(a)
        a.remove(max(a))
    print(apoints - bpoints)

if __name__ == '__main__':
    main()

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

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

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

a_list.sort(reverse = True)

total_dif = 0
for a in range(0,n,2):
    if a+1 ==n:
        total_dif += a_list[a]
    else:
        total_dif += a_list[a]-a_list[a+1]
print(total_dif)

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())
cards = list(map(int,input().split()))
cards_sort = sorted(cards,reverse = True)
Alice = 0
Bob = 0
for i in range(0,N,2):
    Alice += cards_sort[i]
for i in range(1,N,2):
    Bob += cards_sort[i]

ans  =Alice - Bob
print(ans)

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

c.sort()

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

print(abs(a-b))

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

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

print(Alice-Bob)

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

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

b=sorted(a,reverse=True)

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

Solution (Python):
N = int(input())
arr = sorted(list(map(int, input().split())), reverse=True)
alice_total, bob_total = 0, 0

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

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

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

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

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

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

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

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

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

print(abs(ans))

Solution (Python):
N=int(input())
A=0
B=0
for idx, a in enumerate(sorted(map(int, input().split()),reverse=True)):
    if (idx+1)%2:
        A+=a
    else:
        B+=a
print(A-B)

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

Solution (Python):
N = int(input())
a = sorted(map(int, input().split()), reverse=True)
sumA = 0
for x in range(len(a)):

    if x % 2 == 0:
        sumA += a[x]
    else:
        sumA -= a[x]
print(sumA)

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

print(A-B)

Solution (Python):
input()

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

data = sorted(data, reverse=True)
alice = sum(data[::2])
bob = sum(data[1::2])
print(alice - bob)

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

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

Solution (Python):
n=int(input())
a=[int(i) for i in input().split()]
a=sorted(a,reverse=True)
turn=True
b,c=0,0
for i in range(n):
  if turn:
    b+=a[i]
    turn=False
  else:
    c+=a[i]
    turn=True
print(abs(b-c))

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

average = sum(l)
alice = sum(l[::2])
print(alice*2-average)

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

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

lista.sort(reverse=True)

A=B=0

for i in range(len(lista)):
    if i%2==0:
        A+=lista[i]
    else:
        B+=lista[i]
        
print(A-B)

Solution (Python):
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor



dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

N = int(input())
a = readints()

aa = sorted(a, reverse=True)

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

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

def puts(s): 
    print(s)

def puti(i): 
    print(str(i))

A.sort(reverse=True)

alice = 0
bob = 0

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

puti(alice - bob)

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

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

print(bob - alice)

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

a = sorted(a, reverse = True)
x = []
y = []
ans = 0
flg = 0
for i in a:
    if flg == 0:
        ans +=i
        flg = 1
    else:
        ans -=i
        flg = 0
print(ans)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
alice = 0
bob = 0
a.sort()
while True:
    alice += max(a)
    a.pop()
    a.sort()
    if a == []:
        break
    bob += max(a)
    a.pop()
    if a == []:
        break
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):
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)

Score = 0
for i, j in enumerate(a):
	if i & 1 == 0:
		Score += j
	else:
		Score -= j

print(Score)

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

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

print(alice - bob)

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

bob = []
alice = []

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

Solution (Python):
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    A.sort()
    Alice, Bob = 0, 0
    for i in range(N):
        if i % 2 == 0: Alice += A[N-i-1]
        else: Bob += A[N-i-1]
    print(Alice - Bob)

    return 0

if __name__ == "__main__":
    solve()

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

ai.sort(reverse=True)

A = sum(ai[::2])
B = sum(ai[1::2])

print(A-B)

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

if len(cards) % 2 == 0:
    alice = 0
    for i in range(int(N/2)):
        alice = alice + cards[2 * i]
    bob = 0
    for j in range(int(N/2)):
        bob = bob + cards[2 * j + 1]
else:
    alice = 0
    for i in range(int(N/2) + 1):
        alice = alice + cards[2 * i]
    bob = 0
    for j in range(int(N/2)):
        bob = bob + cards[2 * j + 1]
        
print(alice - bob)

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

score = 0
for i, j in enumerate(a_sort):
    if i % 2 == 0:
        score += j
    else:
        score -= j

print(score)

Solution (Python):
input()
cards = sorted([int(x) for x in input().split()], reverse = True)
alice_point = sum([x for i, x in enumerate(cards) if i % 2 == 0])
bob_point = sum([x for i, x in enumerate(cards) if i % 2 != 0])
print(alice_point - bob_point)

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

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

Solution (Python):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    m = 0
    y = 0
    while len(a) > 0:
        m += max(a)
        a.remove(max(a))
        if len(a) == 0:
            break
        y += max(a)
        a.remove(max(a))
    ans = 0
    ans = m - y
    print(ans)
main()

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
Alice = 0
Bob = 0
ans = 0
while len(a) != 0:
    Alice += max(a)
    a.remove(max(a))
    if a:
        Bob += max(a)
        a.remove(max(a))
ans = Alice - Bob
print(ans)

Solution (Python):

def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort(reverse=True)
    alice_score = 0
    bob_score = 0

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

    print(alice_score - bob_score)

if __name__ == '__main__' :
    main()

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

A.sort(reverse=True)

Alice_point = sum(A[::2])
Bob_point = sum(A[1::2])

print(Alice_point - Bob_point)

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

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

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

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

alice_sum = sum(list_N[::2])
bob_sum = sum(list_N[1::2])

ans = alice_sum - bob_sum

print(ans)

Solution (Python):


import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

N = ni()
a = na()

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

print(abs(alice - bob))

Solution (Python):
class CardGameforTwo:
    def __init__(self):
        self.alice_card_list = []
        self.alice_count = 0
        self.bob_card_list =[]
        self.bob_count = 0
        self.total_card_num = 0
        self.card_list = []
    
    def get_card(self, total_card_num, card_list):
        card_list.sort(reverse=True)
        card_num = 0
        for c in card_list:
            if card_num % 2 == 0:
                self.alice_card_list.append(c)
            else:
                self.bob_card_list.append(c)
            card_num +=1
        return self.alice_card_list, self.bob_card_list
    
    def count_result(self, a_card_list, b_card_list):
        for a in a_card_list:
            self.alice_count +=a
        for b in b_card_list:
            self.bob_count +=b
        result = self.alice_count - self.bob_count
        return result

if __name__ == '__main__':
    N = input()
    a =list(map(int, input().split()))
    cgt = CardGameforTwo()
    a_card_list, b_card_list=cgt.get_card(N, a)
    result = cgt.count_result(a_card_list, b_card_list)
    print(result)

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

a.sort(reverse=True)
al = True
al_s = 0
bo_s = 0

for i in a:
    if al:
        al_s = al_s + i
        al = False
    else:
        bo_s = bo_s + i
        al = True

print(al_s - bo_s)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
bob = 0
alice = 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 = 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]
        continue
    bob += a[i]
print(bob - alice)

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

A = 0
B = 0
while len(a) > 0:
  A += max(a)
  a.remove(max(a))
  if len(a) > 0:
    B += max(a)
    a.remove(max(a))
  
print(A-B)

Solution (Python):
firstint = int(input())
inputary = input()
listA= inputary.split()
numlist =[ int(x) for x in listA]
numlist.sort(reverse=True)
Alice = 0
Bob = 0
for index,elm in enumerate(numlist):
    if index % 2 == 0:
        Alice += int(numlist[index])
    else:
        Bob += int(numlist[index])

print(Alice - Bob)

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


if __name__ == '__main__':
    main()

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

l1 = sorted(l, reverse = True)
Alice = 0
Bob = 0
for j in range(len(l)):
    if j % 2 == 0:
        Alice += l1[j]
    else:
        Bob += l1[j]
print(Alice - Bob)

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

alice = 0
bob = 0

for i in range(0, n, 2):
    alice += a_list[i]
for i in range(1, n, 2):
    bob += a_list[i]
    
result = alice - bob
print(result)

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

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

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

a.sort(reverse=True)

alice = sum([x for x in a[0::2]])
bob = sum([x for x in a[1::2]])

print(alice-bob)

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








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

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


resolve()

Solution (Python):








def resolve():
    n=int(input())
    A=list(map(int,input().split()))
    A.sort(reverse=True)
    val=0
    for i in range(n):
        if i%2==0:
            val+=A[i]
        else:
            val-=A[i]

    print(val)



resolve()

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

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

a.sort(reverse=True)
A=[]
B=[]

for i,k in enumerate(a):
    if i%2 == 0:
        A.append(a[i])
               
               
    elif i%2 == 1:
        B.append(a[i])
        
    
print(sum(A)-sum(B))

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=input()
aa=list(map(int,input().split()))
aa.sort(reverse=True)

ab=[0]*2

i=0
for a in aa:
  ab[i%2]+=a
  i+=1

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

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

card.sort()
card.reverse()

p = [0,0]
for i in range(card_num):
  p[i%2] += card[i]
  
print(p[0]-p[1])

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

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

a.sort()
a.reverse()
p = [0,0]
for i in range(N):
    p[i%2] += a[i]

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

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

Solution (Python):
n = int(input())
nums = [int(i) for i in input().split()]
nums.sort(reverse=True)
turn = 0
alice = 0
bob = 0
for i in nums:
    if turn % 2 == 0:
        alice = alice + i
        turn += 1
    else:
        bob = bob + i
        turn += 1
print(alice - bob)

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

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

    ascore = 0
    bscore = 0
    for i in range(N):
        if i%2 == 0:
            ascore += arr[i]
        else:
            bscore += arr[i]

    print(ascore - bscore)
    
resolve()

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

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(reverse=True)
A = sum(a[0:N:2])
B = sum(a[1:N:2])
print(A-B)

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

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

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

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

t.sort(reverse=True)

fis = 0
sec = 0

for i in range(n):
    if i%2==0:
        fis += t[i]
    else:
        sec += t[i]
print(fis-sec)

Solution (Python):



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

    i.sort(reverse=True)
    

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

main()

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

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

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()))
a = 0
b = 0
A.sort(reverse=True)
for i in range(N):
    if i%2 == 0:
        a = a + A[i]
    if i%2 == 1:
        b = b + A[i]
print(a-b)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
i = 0
Alice = []
Bob = []
while i < n:
    if a == []:
        break
    else:
        Alice.append(max(a))
        a.remove(max(a))
    if a == []:
        break
    else:
        Bob.append(max(a))
        a.remove(max(a))
    i += 1
print(abs(sum(Alice) - sum(Bob)))

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


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

Solution (Python):

def Card_Game(n , al):

    al.sort(reverse=True)

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

    ans = sum(Alice) - sum(Bob)

    return ans

def main():
    n = int(input())
    al = list(map(int , input().split()))
    print(Card_Game(n , al))

if __name__ == '__main__':
    main()

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(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 = sorted([int(x) for x in input().split()], reverse = True)
print(sum(A[::2]) - sum(A[1::2]))

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

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

alice_list = a_sorted[::2]
bob_list = a_sorted[1::2]

print(sum(alice_list) - sum(bob_list))

Solution (Python):
N = input()
a = list(map(int, input().split()))
a_sorted = sorted(a, reverse=True)
is_alice = True
a_score = 0
b_score = 0
for num in a_sorted:
    if is_alice == True:
        a_score += num
        is_alice = False
    else:
        b_score += num
        is_alice = True
        
print(a_score - b_score)

Solution (Python):


m = int(input())
a = sorted(list(map(int,input().split())),reverse=True)
p = 0
q = 0
for i in range(len(a)//2):
    p += a[2 * i]
    q += a[2 * i + 1]

if len(a) % 2 != 0:
    p += a[-1]

print(p-q)

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 += c[i]
  else: b += c[i]
print(a-b)

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

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

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

a = []
b = []
l.sort(reverse=True)
for i, r in enumerate(l, start=1):
    if i % 2 == 1:
        a.append(r)
    else:
        b.append(r)
print(sum(a) - sum(b))

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

Solution (Python):

import numpy as np

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

a = np.array(a)
a_sort = np.sort(a)

ans = np.sum(a_sort[-1::-2]) - np.sum(a_sort[-2::-2])
print(ans)

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

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

a.sort(reverse=True)

Alice = 0
Bob = 0
i = 1

for j in a:
    if i % 2 == 1:
        Alice += j
    else:
        Bob += j

    i += 1

print(Alice - Bob)

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

if n % 2:
    a.append(0)
aa = 0
bb = 0
for i in range(0,len(a),2):
    aa += a[i]
    bb += a[i+1]

print(aa-bb)

Solution (Python):

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



A.sort(reverse=True) 


Alice = []
Bob = []

counter = 0

while True:
    if(len(A) == 0):
        break 

    if(counter % 2 == 0): 
        
        Alice.append(A.pop(0))
        counter += 1
    else:
        Bob.append(A.pop(0))
        counter += 1
    




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

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

alice = []
bob = []

for i in range(n):
    if not a:
        break
    max_num = max(a)
    a.remove(max_num)
    alice.append(max_num)
    if not a:
        break
    max_num = max(a)
    a.remove(max_num)
    bob.append(max_num)

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

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

Solution (Python):

num = int(input())
data = list(map(int, input().split()))


alice = 0
bob = 0


data = sorted(data, reverse=True)

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

print(alice - bob)

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
l.sort()
sumA=0
sumB=0
for i in range(1,n+1):
  if i%2==1:
    sumA+=l[(-1)*i]
  else:
    sumB+=l[(-1)*i]
print(sumA-sumB)

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

Solution (Python):

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

a.sort(reverse=True)

res= sum(a[0::2])-sum(a[1::2])

print(res)

Solution (Python):

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

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

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

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

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

A.sort(reverse=True)

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

print(alice - bob)

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

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

a_sum=0
b_sum=0

for i in range((N+1)//2):
    max_value=max(card)
    max_index=card.index(max_value)
    a_sum+=max_value
    card[max_index]=0

    max_value=max(card)
    max_index=card.index(max_value)
    b_sum+=max_value
    card[max_index]=0

print(a_sum-b_sum)

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

a_sum=0
b_sum=0

for i in range((N+1)//2):
    max_value=max(a)
    max_index=a.index(max_value)
    a_sum+=max_value
    a[max_index]=0

    max_value=max(a)
    max_index=a.index(max_value)
    b_sum+=max_value
    a[max_index]=0

print(a_sum-b_sum)

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

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

for i in range(N):
   for j in reversed(range(i+1,N)):
        
        if a[j] > a[j-1]:
            temp = a[j]
            a[j] = a[j-1]
            a[j-1] = temp

Alice = 0
Bob = 0

k = 0
count =1
while k < N:
    if count % 2 == 0:
        Bob += a[k]
    else:
        Alice += a[k]
    k += 1
    count += 1

print(Alice-Bob)

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
a=sorted(a,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):
import math
n=int(input())
a=(list(map(int,input().split())))
a.append(0)
al=0
bo=0
for i in range(0,(n+1)//2,1):
    al+=max(a)
    a.remove(max(a))
    
    bo+=max(a)
    a.remove(max(a))
print(al-bo)

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

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

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

Solution (Python):
n = input()
a = list(map(int,input().split()))
alice = 0
bob = 0
while(a != []):
    alice += max(a)
    a.remove(max(a))
    if(a == []):
        break
    bob += max(a)
    a.remove(max(a))

print(alice-bob)