Felix6326727/beyond-accuracy-code-comprehension huggingface dataset:
N=int(input())
A=int(input())
print(N*N-A)

# Example run
# Input:
1315
204015990
# Output:
-202286765
n = int(input())
a = int(input())
print(n**2 - a)

# Example run
# Input:
-10305
-353364
# Output:
106546389
n = int(input())
print(n * n - int(input()))

# Example run
# Input:
-55649
-7038374
# Output:
3103849575
n=int(input())
a=int(input())
print(n**2-a)

# Example run
# Input:
-233
-48
# Output:
54337
N = int(input())
A = int(input())
print(N**2-A)

# Example run
# Input:
648948451
0
# Output:
421134092055299401
n = int(input())
a = int(input())
print (n * n - a)

# Example run
# Input:
-30
-3011
# Output:
3911
a = int(input())
b = int(input())
print(a*a-b)

# Example run
# Input:
44
237
# Output:
1699
N = int(input())
A = int(input())
print(N * N - A)

# Example run
# Input:
128410
1
# Output:
16489128099
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
select_p, select_q, even = 0, 0, 0
for p, q in zip(P, Q):
  if p > q:
    select_p += p
  elif p < q:
    select_q += q
  else:
    even += p
ans = 0
if select_p < select_q:
  for p, q in zip(P, Q):
    if p > q:
      ans += p
    elif p == q:
      ans += p/2
else:
  for p, q in zip(P, Q):
    if p < q:
      ans += q
    elif p == q:
      ans += p/2
ans /= 100
print(ans)

# Example run
# Input:
2569
30315
# Output:
0.0
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
select_p, select_q, even = 0, 0, 0
for p, q in zip(P, Q):
  if p > q:
    select_p += p
  elif p < q:
    select_q += q
  else:
    even += p
ans = min(select_p, select_q) + even/2
ans /= 100
print(ans)

# Example run
# Input:
237144
1761864
# Output:
0.0
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
select_p, select_q, even = 0, 0, 0
for p, q in zip(P, Q):
  if p > q:
    select_p += p
  elif p < q:
    select_q += q
  else:
    even += p
print(min(select_p, select_q) + even/2)

# Example run
# Input:
5183902
18
# Output:
0.0
import math as m

# f = open('input', 'r')
# P = list(map(lambda x: float(x)/100, f.readline().split()))
# Q = list(map(lambda x: float(x)/100, f.readline().split()))
P = list(map(lambda x: float(x)/100, input().split()))
Q = list(map(lambda x: float(x)/100, input().split()))


def calc(x):
    prob = [max(p*x, q*(1-x)) for p, q in zip(P, Q)]
    return sum(prob)

phi = (1 + m.sqrt(5)) / 2
l, r = 0, 1
x1, x2 = (l*phi + r)/(1 + phi), (l + r*phi)/(1 + phi)
f1, f2 = calc(x1), calc(x2)

while True:
    if f1 > f2:
        l, x1 = x1, x2
        x2 = (l + r*phi)/(1 + phi)
        f1, f2 = f2, calc(x2)
    else:
        x2, r = x1, x2
        x1 = (l*phi + r)/(1 + phi)
        f1, f2 = calc(x1), f1

    if abs(l-r) < 1e-12:
        break
print('%.12lf' % f1)


# Example run
# Input:
627
5460
# Output:
5.624149827502
N = int(input())
A = sorted(list(map(int, input().split())),reverse = True)

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


# Example run
# Input:
-112
-1
# Output:
0
n = int(input())
cards = sorted(list(map(int, input().split())), reverse=True)
alice = []
bob = []
for i in range(0, n, 2):
    alice.append(cards[i])
    try:
        bob.append(cards[i+1])
    except:
        break
print(sum(alice) - sum(bob))

# Example run
# Input:
-1131247330
-9
# Output:
0
n=int(input())
a=list(map(int,input().split()))
a.sort()
a=a[::-1]
b=[a[i] for i in range(len(a)) if i%2==1]
c=[a[i] for i in range(len(a)) if i%2==0]
print(sum(c)-sum(b))

# Example run
# Input:
186860433
108968
# Output:
108968
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
print(sum(a[::2]) - sum(a[1::2]))

# Example run
# Input:
-1
-3439167
# Output:
-3439167
def resolve():
    N = int(input())
    A = list(map(int,input().split()))
    A.sort()
    Alice = A[::-2]
    Bob = A[N-2::-2]
    print(sum(Alice)-sum(Bob))
resolve()    

# Example run
# Input:
-124978655
-23909
# Output:
-23909
#input
N = int(input())
A = list(map(int, input().split()))
#A.sort() # 配列を小さい順に並び替え
A.sort(reverse = True) # 配列を大きい順に並び替え
#print(A)
alice = bob = 0 # 初期化

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


print(alice-bob)

# Example run
# Input:
-52564348
-7737
# Output:
0
N = input()
a = sorted(map(int, input(). split()))
print(sum(a[-1::-2])-sum(a[-2::-2]))

# Example run
# Input:
},1x@K_
991741
# Output:
991741
N = int(input())
a = input().split()
a = [int(i) for i in a]

Bob=0
Alice=0

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


# Example run
# Input:
-124978655
-23909
# Output:
0
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)

# Example run
# Input:
-1794
-1147387
# Output:
<built-in function sum>
N = int(input())
a = list(map(int, input().split()))
Alice = 0
Bob = 0

a = sorted(a, reverse=True)

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

print(Alice - Bob)

# Example run
# Input:
-2
-28797
# Output:
0
N=int(input())
a=list(map(int,input().split()))
a=sorted(a,reverse=True)
sum_a = sum(a)
x_sum = 0
for x in range(0,len(a),2):
    x_sum += a[x]

y_sum = sum_a - x_sum

print(x_sum - y_sum)

# Example run
# Input:
0
1418198351
# Output:
1418198351
N = int(input())
numlist=list(map(int,input().split()))#リストに対してしか実行できない関数を使うため、入力した値をリスト化する
sortnumlist=sorted(numlist,reverse=True)#リストの中身を降順にしたやつをsortnumlistと言う変数名つけた

#リストのインデックス０、２、４・・・の合計がAliceの得点、１、３、５・・・の合計がBobの得点に等しい

alice_total = 0#Aliceの得点を初期化
bob_total = 0#Bobの得点を初期化
for x,y in enumerate (sortnumlist):#リストの要素のインデックスと値を別々に取り出す
    if x %2 ==0:
        alice_total = alice_total + y
    elif x %2 ==1:
        bob_total = bob_total + y
        
#print(alice_total)
#print(bob_total)

answer = alice_total  - bob_total
print(answer)


# Example run
# Input:
-318594
-13
# Output:
-13
n = int(input())
card = list(map(int, input().split()))
alice = 0
bob = 0

card.sort(reverse = True)
for i in range(n):
    if i % 2 == 0:
        alice += card[i]
    else:
        bob += card[i]
print(alice - bob)

# Example run
# Input:
1
61070189
# Output:
61070189
#88b
n=int(input())
a = list(map(int,input().split()))
a=sorted(a,reverse=True)
x=sum(a[::2])
y=sum(a[1::2])
print(x-y)

# Example run
# Input:
-87
5357240
# Output:
5357240
N = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
print(sum(a[::2]) - sum(a[1::2]))


# Example run
# Input:
244278
112781417
# Output:
112781417
#ABC 088 B

N = int(input())
x = list(map(int,input().split()))
x = sorted(x, reverse=True)
a = 0
b = 0
ans = 0

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

# Example run
# Input:
-224960337
446
# Output:
446
n = int(input())
a = list(map(int, input().split()))
ans = 0

a.sort(reverse=True)
a.append(0)

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

print(ans)


# Example run
# Input:
-7
367663
# Output:
0
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))

N = int(input())
A = sorted(inpl(), reverse=True)
print(sum(A[::2]) - sum(A[1::2]))

# Example run
# Input:
-42245
-2503
# Output:
-2503
import math
N = int (input ())
l = input ().split ()
list.sort (l)
print (l)
a = 0
x = 0
m = math.ceil(N/2)
for i in range (m):
    x += int (l[a])
    a += 2
b = 1
y = 0
for j in range (N-m):
    y += int (l[b])
    b += 2
print (y-x)

# Example run
# Input:
-124978655
zW>KkL
# Output:
['zW>KkL']
0
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
A,B = [],[]
for num in range(n):
    if(num == 0 or num % 2 == 0):
        A.append(a[num])
    else:
        B.append(a[num])
print(sum(A)-sum(B))

# Example run
# Input:
-31
-58867430
# Output:
0
n = int(input())
nums = [int(i) for i in input().split()]
nums.sort(reverse=True)
print(sum(nums[::2]) - sum(nums[1::2]))

# Example run
# Input:
332914
793
# Output:
793
input()
a=sorted(map(int,input().split()))[::-1]
print(sum(a[::2])-sum(a[1::2]))

# Example run
# Input:
UKydg
14707
# Output:
14707
#AtCorder Beginner Contest 088 B Card Game for Two

#number of cards
n = int(input())

#cards in the field
line = list(map(int,input().split()))
pointA = 0
pointB = 0

while len(line) > 0:
    pointA += max(line)
    line.remove(max(line))
    if len(line) == 0:
        break
    else:
        pointB += max(line)
        line.remove(max(line))

print(pointA-pointB)


# Example run
# Input:
25093324
7468
# Output:
7468
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
alice = sum([a[i] for i in a if i%2 == 0])
bob = sum([a[i] for i in a if i%2 == 1])
print(alice-bob)


# Example run
# Input:
446
0
# Output:
0
N = int(input())
A = list(map(int,input().split()))
#print(N,A)

sort_A = sorted(A,reverse=True)
#print(sort_A)

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

print(Alice - Bob)

# Example run
# Input:
-91
0
# Output:
0
input()
a = list(map(int, input().split()))
a.sort(reverse=True)

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

print(alice - bob)


# Example run
# Input:
l[aA$[><G
1008752943
# Output:
1008752943
n = int(input())
a_list = list(map(int, input().split()))
a_list.sort(reverse=True)

alice_sum = 0
bob_sum = 0
for i in range(n):
    if i % 2 == 0:
        alice_sum += a_list[i]
    else:
        bob_sum += a_list[i]

print(alice_sum - bob_sum)


# Example run
# Input:
-69520
-73864104
# Output:
0
N = int(input())
A = list(map(int,input().split()))
A.sort()

ali = bob = 0
for i,a in enumerate(reversed(A)):
    if i%2:
        bob += a
    else:
        ali += a
print(ali - bob)

# Example run
# Input:
32
-836
# Output:
-836
N = int(input())
a = sorted(list(map(int, input().split())))
ans = 0
for i in range(N):
    if i % 2 == 0:
        ans += a[-1]
        a.pop()
    else:
        ans -= a[-1]
        a.pop()
print(ans)

# Example run
# Input:
-22
-2334
# Output:
0
n = int(input())
a = list(map(int, input().split(" ")))
a = sorted(a, reverse=True)
al = a[::2]
bo = a[1::2]
print(sum(al) - sum(bo))

# Example run
# Input:
125090213
380581
# Output:
380581
N = int(input())
A = sorted(list(map(int, input().split())))[::-1]
print(sum(A[::2])-sum(A[1::2]))


# Example run
# Input:
542366274
1
# Output:
1
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))

# Example run
# Input:
44169557
2069520666
# Output:
2069520666
n = int(input())
l = list(map(int, input().split()))
a = 0
b = 0

l = sorted(l, reverse=True)
for i in range(n):
    if i%2 == 0:
        a += l[i]
    else:
        b += l[i]
print(a-b)

# Example run
# Input:
-224852
-318594
# Output:
0
n = int(input())
a = sorted(list(map(int, input().split())))[::-1]
print(sum(a[0::2])-sum(a[1::2]))

# Example run
# Input:
-28418
-29
# Output:
-29
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)



# Example run
# Input:
-23909
-68
# Output:
0
N = int(input())
 
if N%2 == 0:
  print(N/2)
else:
  N += 1
  print(N/2)

# Example run
# Input:
4345
# Output:
2173.0
n = int(input())
import collections
dat = list(map(int, input().split()))
dat.sort(reverse=True)
dat = collections.deque(dat)
resa , resb = 0,0

while len(dat) != 0:
    resa += dat.popleft()
    if len(dat) ==0:
        break
    resb += dat.popleft()

print(resa - resb)


# Example run
# Input:
370
102055
# Output:
102055
n = int(input())

num = [int(i) for i in input().split()]
nums = sorted(num,reverse = True)
print(sum(nums[::2]) - sum(nums[1::2]))
                        

# Example run
# Input:
0
-6865
# Output:
-6865
N = int(input())

cards = [data for i, data in enumerate(sorted(map(int, input().split(" ")), reverse=True))]
print(sum(cards[0::2]) - sum(cards[1::2]))

# Example run
# Input:
22349
-2031692
# Output:
-2031692
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
from math import ceil

n=ni()
a=nl()

sa = sorted(a)[::-1]
aa = []
bb = []
for i in range(n):
  if i%2==0:
    aa.append(sa[i])
  else:
    bb.append(sa[i])

print(sum(aa)-sum(bb))


# Example run
# Input:
-1
-3439167
# Output:
0
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)


# Example run
# Input:
0
-14125092
# Output:
-14125092
N=int(input())
a = list(map(int, input().split()))
b=sorted(a, reverse=True)
print(sum(b[0::2])-sum(b[1::2]))

# Example run
# Input:
-377
-491914923
# Output:
-491914923
n = int(input())
a_list = sorted(map(int, input().split()), reverse=True)

alice_score = sum(a_list[0::2])
bob_score = sum(a_list[1::2])

print(alice_score - bob_score)

# Example run
# Input:
-1
-3439167
# Output:
-3439167
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)

# Example run
# Input:
0
11
# Output:
0
N=int(input())
a=list(map(int,input().split()))
a=sorted(a,reverse=True)
sc=[0,0]
for i,ai in enumerate(a):
    sc[i%2]+=ai
print(sc[0]-sc[1])


# Example run
# Input:
186860433
108968
# Output:
108968
n=int(input())
a=sorted([int(x) for x in input().split()],reverse=True)

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

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


# Example run
# Input:
11
4082171
# Output:
4082171
n = int(input())
a = list(map(int,input().split()))
cnt = 0

a.sort(reverse=True)

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

print(cnt)


# Example run
# Input:
-4868286
-104837
# Output:
0
n = int(input())
a = list(map(int,input().split()))
a.sort()
a.reverse()
print(sum(a[::2])-sum(a[1::2]))


# Example run
# Input:
28210012
7348
# Output:
7348
def resolve():
    n=int(input())
    l=list(map(int, input().split()))
    l.sort(reverse=True)
    l_A=l[::2]
    l_B=l[1::2]
    print(sum(l_A)-sum(l_B))
resolve()

# Example run
# Input:
3420734
-989028
# Output:
-989028
n=int(input())
a=sorted(list(map(int,input().split())),reverse=True)
print(sum(a[::2])-sum(a[1::2]))

# Example run
# Input:
2072477
30125521
# Output:
30125521
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)

# Example run
# Input:
-2773
3897539
# Output:
0
n = int(input())
a = sorted(list(map(int,input().split())))
a.reverse()
Alice = []
Bob = []
for i,p in enumerate(a):
    if i % 2 == 0:
        Alice.append(p)
    else:
        Bob.append(p)
print (sum(Alice) - sum(Bob))

# Example run
# Input:
-11385106
-114
# Output:
-114
_ = input()
*a, = map(int, input().split())
a = sorted(a)[::-1]
print(sum(a[::2])-sum(a[1::2]))

# Example run
# Input:
zNh
-1045001
# Output:
-1045001
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))
alice = 0
bob = 0
a.sort()

for i in range(len(a)):
    if i % 2 == 0:
        alice += a.pop()
    else:
        bob += a.pop()

print(alice - bob)


# Example run
# Input:
0
-84521052
# Output:
-84521052
N = input()
A = [int(x) for x in input().split()]

A = sorted(A, reverse=True)

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

# Example run
# Input:
M<^u"-i
1065258
# Output:
1065258
n=int(input())
*a,=map(int,input().split())
a.sort(reverse=True)
A=a[::2]
B=a[1::2]
print(sum(A)-sum(B))

# Example run
# Input:
45236
197766
# Output:
197766
_ = input()
l = [int(x) for x in input().split()]
l.sort(reverse=True)

alices_score = sum([x if i % 2 == 0 else 0 for i, x in enumerate(l)])
bobs_score = sum([x if i % 2 != 0 else 0 for i, x in enumerate(l)])

print(alices_score - bobs_score)

# Example run
# Input:
fWhX
166355
# Output:
166355
N = int(input())
a = list(map(int, input().split()))
a_sorted = sorted(a, reverse = True)

A, B = 0, 0

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

print(A-B)

# Example run
# Input:
-563
56
# Output:
0
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)

# Example run
# Input:
-5024207
-2147483648
# Output:
0
n=int(input())
a=list(map(int,input().split()))
aa=sorted(a)
ans1=0
ans2=0
for i in range(n):
  if i%2==0:
    ans1+=aa[i]
  else:
    ans2+=aa[i]
print([ans2-ans1,ans1-ans2][n%2])

# Example run
# Input:
-28
-2
# Output:
0
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()


# Example run
# Input:
-2239572
-31
# Output:
-31
N=int(input())
A=sorted(map(int,input().split()))
print(sum(A[::2])*2-sum(A))

# Example run
# Input:
-5900
-802253
# Output:
-802253
#B
n = int(input())
a = list(map(int, input().split()))
a_1 =  sorted(a, reverse=True)

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

# Example run
# Input:
-38181262
41286958
# Output:
41286958
N = int(input())
a_list = [int(i) for i in input().split()]

ans = 0
flag = True
for a in sorted(a_list, reverse=True):
    if flag:
        ans += a
    else:
        ans -= a
    flag = not flag
print(ans)


# Example run
# Input:
8131
1813543
# Output:
1813543
N = int(input())
hands = list(map(int,input().split()))
Alice = 0
Bob = 0
for i in range(N):
    ans = hands.pop(hands.index(max(hands)))
    if i % 2 == 0:
        Alice += ans
    else:
        Bob += ans
print(Alice - Bob)

# Example run
# Input:
-7930
-86
# Output:
0
input()
lis = sorted(list(map(int, input().split())), reverse=True)
print(sum(lis[0::2]) - sum(lis[1::2]))

# Example run
# Input:
0JCNR'
115625
# Output:
115625
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)


# Example run
# Input:
1
-10081
# Output:
-10081
N = int(input())
a_list = [int(i) for i in input().split(" ")]

alice = 0
bob = 0
for n, a in enumerate(sorted(a_list, reverse=True)):
    if n % 2 == 0:
        alice += a
    else:
        bob += a

print(alice-bob)


# Example run
# Input:
56
1
# Output:
1
# 2020-08-30, Sun

n = int(input())
lis = sorted(list(map(int, input().split())), reverse=True)
a = 0
b = 0

for i in lis[::2]:
    a += i

for i in lis[1::2]:
    b += i

print(a - b)

# Example run
# Input:
456
212
# Output:
212
import heapq

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

heapq.heapify(a)

x = 0
y = 0

for i in range(len(a)):
    if i % 2 == 0:
        x += heapq.heappop(a)
    else:
        y += heapq.heappop(a)

print(abs(x - y))



# Example run
# Input:
-83
-39355
# Output:
39355
n = int(input())
a = list(map(int, input().split()))
a.sort()
a.reverse()
print(sum(a[::2]) - sum(a[1::2]))

# Example run
# Input:
-2243514
5183902
# Output:
5183902
n = int(input())

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

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


# Example run
# Input:
-253690
-1
# Output:
0
N=int(input())
a=[int(x) for x in input().split()]
Alice=0
Bob=0
for i in range(N):
  if i%2==0:
    Alice=Alice+max(a)
    a.remove(max(a))
  else:
    Bob=Bob+max(a)
    a.remove(max(a))
print(Alice-Bob)

# Example run
# Input:
0
-6956
# Output:
0
a = int(input())
b = list(map(int,input().split()))
c = sorted(b,reverse=True)
print(sum(c[0:a:2])-sum(c[1:a:2]))

# Example run
# Input:
-375
14322
# Output:
0
def solve():
    N = int(input())

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

    sorted_cards = sorted(cards, reverse=True)

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

    print(Alice-Bob)


solve()

# Example run
# Input:
-126905272
28016
# Output:
28016
N=int(input())
A=list(map(int, input().split()))
A.sort(reverse=True)
sum1=0
sum2=0
for num in range(N+1):
  if num % 2 ==0:
    sum1 += A[num]
  else:
    sum2 += A[num]
print(sum1-sum2)

# Example run
# Input:
-802
363865392
# Output:
0
N = int(input())
D = list(map(int,input().split()))
D.sort(reverse = True)
A = []
B = []
for i in range(N):
    if i%2==0:
        A.append(D[i])
    else:
        B.append(D[i])
 
print(sum(A)-sum(B))


# Example run
# Input:
1
2
# Output:
2
input();
al=[int(i) for i in input().split()]
al.sort()
al = al[::-1]
print(sum(al[::2])-sum(al[1::2]))

# Example run
# Input:
$[><G
1008752943
# Output:
1008752943
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

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

print(als - bob)

# Example run
# Input:
-58743
-207
# Output:
-207
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)


# Example run
# Input:
-10
13637464
# Output:
13637464
# -*- coding:utf-8 -*-
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)

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


# Example run
# Input:
-83
-39355
# Output:
[-39355]
0
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
b=a[1::2]#偶数番目
print(sum(a)-sum(b)*2)


# Example run
# Input:
1949
0
# Output:
0
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()


# Example run
# Input:
113162947
-2540
# Output:
-2540
n=(int(input())+1)%2
print(sum(k if i%2==n else -k for i,k in enumerate(sorted(map(int,input().split())))))

# Example run
# Input:
39756387
-7467726
# Output:
-7467726
N=input()
a=list(map(int,input().split()))

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

# Example run
# Input:
My>_*s
-15015728
# Output:
-15015728
n=int(input())
x=list(map(int, input().split()))
x.sort(reverse=True)
if n%2==1:
  x.append(0)
ans=0
for i in range(0,n,2):
  ans+=(x[i]-x[i+1])
print(ans)

# Example run
# Input:
-56661351
981571
# Output:
0
"""abc088_b"""
N = int(input())
A = list(map(int, input().split()))

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


# Example run
# Input:
-420
627
# Output:
627
n=int(input())
a=list(reversed(sorted([int(i) for i in input().split()])))
sum=0
for i in range(n):
  if i%2==0:
    sum += a[i]
  else:
    sum -= a[i]
print(sum)    

# Example run
# Input:
-2
669
# Output:
0
import heapq
n = int(input())
A = list(map(lambda x: int(x)*(-1),input().split()))
heapq.heapify(A)
# even if you heapfied your list the type is still list
#print(type(A))
al = []
bo = []
for i in range(n):
  if i % 2 == 0:
    al.append(heapq.heappop(A)*(-1))
  else:
    bo.append(heapq.heappop(A)*(-1))
print(sum(al)-sum(bo))

# Example run
# Input:
-264371717
10366
# Output:
0
def resolve():
    n = int(input())
    a = sorted(list(map(int, input().split())), reverse=True)
    print(sum(a[::2]) - sum(a[1::2]))


if __name__ == "__main__":
    resolve()


# Example run
# Input:
109
447
# Output:
447