peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
from collections import defaultdict

memo = dict()

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

for i in range(m):
    p, s = input().split()
    if p not in memo:
        memo[p] = [0, False]

    if memo[p][1]:
        continue

    v = memo[p]
    if s == 'AC':
        memo[p] = [v[0], True]
    else:
        memo[p] = [v[0]+1, False]        

ac, wa = 0, 0
for _,v in memo.items():
    w, a = v
    if a:
        ac += 1
        wa += w

print(ac, wa)
# Judge status: Accepted
N = int(input())
P = list(map(int, input().split()))

ans = 0

for i in range(N):
    if P[i] != i+1:
        continue
    if i+1 < N and P[i] != i+2 or i == 0:
        P[i], P[i+1] = P[i+1], P[i]
        ans += 1
    else:
        P[i], P[i-1] = P[i-1], P[i]
        ans += 1

print(ans)
# Judge status: Accepted
n , x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
cou = 0
for i in range(n):
    cou += a[i]
    if cou > x:
        print(i)
        exit()
if cou == x:
    print(n)
else:
    print(n-1)
# Judge status: Wrong Answer
# coding: utf-8
def main():
	d,t,s = map(int, input().split())
	if t-(d*s) >= 0:
		print('Yes')
	else:
		print('No')


if __name__ == '__main__':
	main()
# Judge status: Wrong Answer
n=int(input())
s=input()
if n%2==1:
    print('No')
else:
    for i in range(len(s)//2):
        if s[i]==s[i+len(s)//2]:
            print('Yes')
        else:
            print('No')
# Judge status: Accepted
a,b,c = map(int, input().split())
print('YNeos'[a+b<c::2])
# Judge status: Accepted
S=list(input())
T=list(input())
def shift(l):
  return l[1:]+l[:1]
for i in range(len(S)):
  S=shift(S)
  if S==T:
    print("Yes")
    exit()
print("No")
# Judge status: Wrong Answer
S = input()
l = list(S)

#odd loop
for i in range(0,len(S),2):
    if l[i] == 'L':
        print('NO')
        exit()

#even loop
for j in range(1, len(S), 2):
    if l[j] == 'R':
        print('NO')
        exit()

print('YES')
# Judge status: Accepted
S = input()

if S == 'AAA' or  S == 'BBB':
    print('No')
else:
    print('Yes')
# Judge status: Accepted
import math

k = int(input())
sum = 0

for a in range(k):
    for b in range(k):
        aandb = math.gcd(a+1, b+1)
        for c in range(k):
            sum += math.gcd(aandb, c+1)

print(sum)
# Judge status: Wrong Answer
A,B = map(int,input().split())

import fractions
C = fractions.gcd(A,B)
print(A*B/C)
# Judge status: Accepted
N=int(input())
a=str(N)
if '7' in a:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
s=input()
n=len(s)
ans=[0]*(n+1)
if s[0]=='<':
  ans[0]=0
else:
  ans[0]=1
  
for i in range(0,n):
  if s[i]=='<':
    ans[i+1]=ans[i]+1
for i in range(n-1,0,-1):
  if s[i]=='>':
    ans[i]=max(ans[i+1]+1,ans[i])
print(sum(ans))
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
a,b,c = list(map(int,input().split()))
if a <= b <= c:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
h, n = map(int, input().split())
a = list(map(int, input().split()))
print("Yes" if h - sum(a) <= 0 else "No")
# Judge status: Wrong Answer
X,N=[int(s) for s in input().split()]
p = [int(s) for s in input().split()]
prelist =  list(range(1,101))
a =100

for i in range(len(p)):
    prelist.remove(p[i])

for j in range(len(prelist)):
    if(abs(X-a) != min(abs(X-a),abs(X-prelist[j]))):
        a = prelist[j]
print(a)
# Judge status: Wrong Answer
import math

N = int(input())
X = list(map(int, input().split()))
sum = 0
all = True
max = 0
for a in X:
    sum = sum + a
    if max < a:
        max = a -1
    for c in X:
        if(a != c):
            all = False
ans = 0
for b in X:
    ans = ans + (b-math.ceil(max))**2
if all == True:
    ans = 0
    print(ans)
else:
    print(ans)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)[::-1]
ans = sum(a[:2*n:2])
print(ans)
# Judge status: Accepted
N = int(input())
H = [int(j) for j in input().split()]
maximum = 0
cnt = 0
for i in range(0,N-1):
    
    if H[i] >=H[i+1]:
        cnt+=1
        if maximum < cnt:
            maximum = cnt
    else:
        cnt=0
        
print(maximum)
# Judge status: Wrong Answer
L, R, d = map(int, input().split())
count = 0
for i in range(L + 1, R):
    if i % d == 0:
        count += 1
print(count)
# Judge status: Accepted
n,m=map(int,input().split())
nl=[list(map(int,input().split())) for i in range(n)]
ml=[list(map(int,input().split())) for i in range(m)]

for j in range(n):
  best=100000000000
  for i in range(m):
    d=abs(ml[i][0]-nl[j][0]) + abs(ml[i][1]-nl[j][1])
    if best>d:
      best=d
      ans=i+1
  print(ans)
# Judge status: Accepted
a, b = map(int, input().split())

def it():
    for x in range(a, b+1):
        x = str(x)
        if x[0] == x[4] and x[1] == x[3]:
            yield 1

print(sum(it()))
# Judge status: Accepted
s = input()
ans = "ABC"
if s =="ABC":
    ans = "ARC"
print(ans)
# Judge status: Wrong Answer
N = int(input())
a = list(map(int, input().split()))
c = []
i=1
for k in range(N): 
    if a[k]==i:
        i += 1
    else:
        c.append(a[k])
if len(c)>= len(a):
    print(-1)
else:
    print(len(a)-len(c))
# Judge status: Wrong Answer
A=int(input())
c=A//10
if A%10==0:
  print(c**2+8)
elif A<10:
  print(A)
else:
  n=A%10
  t=len(str(A))
  b=A//10**(t-1)
  if n>=b:
    print(c**2+2*c+9)
  else:
    print(c**2+2*c+6)
# Judge status: Wrong Answer
print((lambda x:(x[1]+x[2]-x[0]))(list(map(int,input().split()))))
# Judge status: Accepted
n = int(input())
blue_card = {}
for _ in range(n):
    s = input()
    if s not in blue_card:
        blue_card[s] = 1
    else:
        blue_card[s] += 1

m = int(input())
red_card = {}
for _ in range(m):
    s = input()
    if s not in red_card:
        red_card[s] = 1
    else:
        red_card[s] += 1
max_diff = 0
for s in blue_card:
    if s not in red_card:
        red_card[s] = 0
    diff = blue_card[s] - red_card[s]
    max_diff = max(max_diff, diff)
print(max_diff)
# Judge status: Accepted
nums = list(input().split())
c = 0
for i in nums:
    c = c+1
    if i == '0':
        print(c)
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
mod=10**9+7

data=[0 for i in range(0,60)]

for i in range(0,N):
    for j in range(0,60):
        data[j]+=(A[i]>>j &1)

ans=0
for i in range(0,60):
    ans=(ans+pow(2,i,mod)*data[i]*(N-data[i]))%mod

print(ans)
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
for i in [a,b,c]:
  if i%2==0:
    print(0)
    break
else:
  s=a*b*c/max(a,b,c)
  print(int(s))
# Judge status: Wrong Answer
from bisect import bisect_left
n=int(input())
A=[int(input()) for _ in range(n)][::-1]

DP=[A[0]]
for i in range(1,n):
    num=A[i]
    if DP[-1]<=num:
        DP.append(num)
    else:
        index=bisect_left(DP,num)
        DP[index]=num
print(len(DP))
# Judge status: Accepted
import math
f= False

x=int(input())
for i in range(x):
	for j in range(1, 1+int(math.sqrt(x))):
		for k in range(2,10):
			if x == j**k:
				print(x)
				f=True
				break
		if f:
			break
	if f:
		break
	x-=1
# Judge status: Wrong Answer
import collections as c
import sys
s = input()
l = len(s)

if l == 1:
	print("YES")
else:
	S = c.Counter(list(map(str,s)))

	if len(S.keys()) <= 2:
		if l == 2:
			print("YES")
		else:
			print("NO")
		sys.exit()

	cnt = set(list(S.values()))

	if len(cnt) == 3:
		print("NO")
	elif len(cnt) == 2:
		a,b = cnt
		if abs(a-b) <= 1:
			print("YES")
		else:
			print("NO")
	else:
		print("YES")
# Judge status: Accepted
N = int(input())
nStr = str(N)
digit = int(nStr[-1])
hon = [2,4,5,7,9]
pon = [0,1,6,8]
bon = [3]
if digit in hon:
	print('hon')
elif digit in pon:
	print('pon')
else:
	print('bon')
# Judge status: Wrong Answer
a, b, h = [int(input()) for i in range(3)]

print((a + b) * h / 2)
# Judge status: Wrong Answer
n,m = map(int,input().split())
ka = [0]*n
L = []
for i in range(n):
    ka = list(map(int,input().split()))
    L += ka[1:]
    if n == 1:
        L += ka[1:]
dup = [x for x in set(L) if L.count(x) == 3]
print(len(dup))
# Judge status: Wrong Answer
K = int(input())
import math
import itertools


def better_gcd(a,b,c):
    tup = set((a,b,c))
    kinds = len(tup)
    if kinds == 3:
        return math.gcd(a, math.gcd(b, c)) * 6
    elif kinds == 2:
        return math.gcd(*tup) * 3
    else:
        return a

ans = 0
cands = list(itertools.combinations_with_replacement(range(200), 3))
for c in cands:
    ans += better_gcd(*c)
print(ans)
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
x = int(input())

ans = (x // 11)
point = ans * 11
ans *= 2
#print(point)
while point < x:
    if ans % 2 == 0:
        point += 5
        ans += 1
    else:
        point += 6
        ans += 1
print(ans)
# Judge status: Wrong Answer
N,M,K = map(int,input().split())
for a in range(N+1):
    for b in range(N+1):
        k = a*b + (N-a)*(M-b)
        if k==K:
            print('Yes')
            exit()
print('No')
# Judge status: Wrong Answer
N = input()
A = list(map(int, input().replace('-', '').split()))
print(sum(A))
# Judge status: Accepted
A = list(map(int, input().split()))
A = sorted(A)
B = str(A[2]) + str(A[1])
print(int(B)+ A[0])
# Judge status: Wrong Answer
N = int(input())
cnt = []
for i in range(N):
    a,b= map(int, input().split())
    if a == b:
        cnt.append(1)
    else:
        cnt.append(0)

from itertools import groupby
gr = groupby(cnt)
for key, group in gr:
    if len(list(group)) >= 3:
        print('Yes')
        exit()
print('No')
# Judge status: Accepted
k, x = list(map(int, input().rstrip().split()))
if 500 * k >= x:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
n,d=map(int,input().split())
x=[]
out=0
for i in range(n):
    x.append(list(map(int,input().split())))

for i in range(n):
    for j in range(i+1,n):
        tol=0
        for k in range(d):
            tol+=(x[i][k]-x[j][k])**2
        print(tol)
        if tol**(1/2)-int(tol**(1/2))==0:
            out+=1
print(out)
# Judge status: Wrong Answer
n = int(input())
if n:
    arr = list(map(int, input().split()))
    t = 0
    for i in set(arr):
        t += i
    print(abs(n-t))
else:
    print(n)
# Judge status: Accepted
#Problem A

a = int(input())

print(a+a**2+a**3)
# Judge status: Accepted
A, B = map(int, input().split())

ans = 0
for i in range(A, B + 1):
    if str(i) == str(i)[::-1]:
        ans += 1
print(ans)
# Judge status: Accepted
A,B,T=map(int,input().split())
print((T//A)*B)
# Judge status: Wrong Answer
n, l = map(int, input().split())
s = [input() for _ in range(n)]
s.sort()
''.join(s)
# Judge status: Wrong Answer
x = int(input())
print((x//11) * 2  + (x % 11 > 5))
# Judge status: Wrong Answer
x,y=(int(i) for i in input().split())  
ans=[]
count=0
for i in range(x,y):
	n=str(i)
	if n[0]==n[-1] and n[1]==n[-2]:
		count +=1
print(count)
# Judge status: Accepted
n,k=map(int,input().split())
a = [int(input()) for i in range(n)]
a = sorted(a)
min_ = 10**18
for i in range(n-k+1):
  min_ = min(min_, a[i+k-1]-a[i])
print(min_)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
count =0
for i in range(N):
  if A[i] >= B[i]:
    count += B[i]
  elif A[i] < B[i]:
    A[i+1] = A[i+1] - (B[i] - A[i])
    count += B[i]
print(count)
# Judge status: Accepted
import bisect
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort()
b.sort()
c.sort()
ans = 0

for i in b:
    ans += bisect.bisect_left(a, i)*(n-bisect.bisect_right(c, i))

print(ans)
# Judge status: Accepted
n = int(input())
p = list(map(int, input().split()))

for i in range(n):
    p[i] -= 1

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

if p[n-1] == n-1:
    ans += 1
print(ans)
# Judge status: Accepted
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
for i in range(n):
	x = int(input())
	for h in range(3):
		for w in range(3):
			if a[h][w] == x:
				a[h][w] = 0
for i in range(3):
	if a[i][0] == a[i][1] == a[i][2] == 0:
		print("Yes")
		exit()
	elif a[0][i] == a[1][i] == a[2][i] == 0:
		print("Yes")
		exit()
if a[0][0] == a[1][1] == a[2][2] == 0:
	print("Yes")
elif a[2][0] == a[1][1] == a[0][2] == 0:
	print("Yes")
else:
	print("No")
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i, j in enumerate(A):
    ans += B[j - 1]
    if i == N - 1:
        break
    elif j + 1 == A[i + 1]:
        ans += C[j - 1]

print(ans)
# Judge status: Wrong Answer
A, B = map(int, input().split())
for i in range(B):
    if A * i % B == 0:
        print(A * i)
        exit(0)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
m = a[0]
s = 0
for i in range(1,n):
    m = max(m,a[i])
    s += m-a[i]
print(s)
# Judge status: Accepted
N = int(input())

def nega_binary(num):
    if num == 0:
        return 0
    res = []
    while num != 0:
        remainder = abs(num) % 2
        res.append(str(remainder))
        if num < 0 and remainder:
            num -= 1
        num = int(num / -2)
    return ''.join(reversed(res))

print(nega_binary(N))
# Judge status: Accepted
s=input()
t=len(s)
ans=0
ruiseki=[int(s[-1]) for i in range(t)]
for i in range(1,t):
    ruiseki[i]=(ruiseki[i-1]+int(s[-1-i])*pow(10,i,2019))%2019
from collections import Counter
ans+=ruiseki.count(0)
C=Counter(ruiseki)
for x in C.values():
    ans+=x*(x-1)//2
print(ans)
# Judge status: Wrong Answer
n = int(input())
list = []
for i in range(0, n):
    if i%5==0 or i%3==0:
        a = 1
    else:
        list.append(i)
print(sum(list))
# Judge status: Accepted
AB, BC, CA = map(int,input().split())
print(AB*BC//2)
# Judge status: Accepted
import math

n = int(input())
i = n

while True:
    x = int(math.sqrt(i))
    if x ** 2 == i:
        ans = i
        break
    i -= 1
print(ans)
# Judge status: Accepted
n = int(input())
dl = list(map(int, input().split()))

MOD = 998244353
ans = 0
d_comb = [0]*n

if dl[0] == 0:
    ans = 1
    d_comb[0] = 1
else:
    print(0)
    exit()

dl.sort()
if n == 1:
    print(1)
    exit()
elif dl[1] == 0:
    print(0)
    exit()

for d in dl[1:]:
    ans *= d_comb[d-1]
    d_comb[d] += 1
    ans %= MOD

print(ans)
# Judge status: Accepted
N = int(input())
ans = 0

for i in range(1,N+1):
  if i%2 == 1:
    ans=ans+1
print(ans/N)
# Judge status: Accepted
X = int(input())

n5 = {}
for i in range(100000):
    n5[i**5] = i    

for i in range(-1000000, 1000000):
    b = i ** 5 + X
    if b in n5:
        print(n5[b], i)
        break
# Judge status: Accepted
import math
N,X,T = map(int, input().split())
print(math.ceil(N/X) * T)
# Judge status: Wrong Answer
N = input()
if len(N)==1:
    print(int(N))
else:
    if all(i=='9' for i in N):
        print(9*len(N))
    else:
        print(int(N[0])-1 + 9*(len(N)-1))
# Judge status: Accepted
N,K=map(int,input().split())
L=[]
ans=float("inf")
for i in range(N):
	L.append(int(input()))
L=sorted(L)
for i in range(N-K+1):
	ans=min(ans,L[i+K-1]-L[i])
print(ans)
# Judge status: Accepted
def get_gcd(a, b):
    if a<b:a,b=b,a
    if b == 0 :return a
    else:return get_gcd(b,a%b)

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

gcd = a[0]
for i in range(1,n):
    gcd = get_gcd(gcd,a[i])
print(gcd)
# Judge status: Accepted
s = input()
if s[0] == s[1] or s[1] == s[2] or s[2] == s[3]:
  print('Bad')
else:
  print('Good')
# Judge status: Accepted
n, m, k = map(int,input().split())

ANS = [0] * (n*m + 1)

for i in range(n+1):
    for j in range(m+1):
        ANS[i*j + (n-i)*(m-j)] = 1
# print(ANS)
if ANS[k] == 1:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
def saiki(n , t , maxi):

    saikimaxi = 0
    for i in range(n):
        if maxi % t[i] != 0:
            saikimaxi = max(saikimaxi , t[i])

    if saikimaxi != 0:
        return saiki(n , t , (maxi * saikimaxi))
    else:
        return maxi

def multiclocks(n , t):

    maxi = max(t)
    return saiki(n , t , maxi)

def main():
    n = int(input())
    t = [int(input()) for i in range(n)]
    print(multiclocks(n , t))

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))+[float('inf')]
ans = 0
for i in range(N-1):
  ans+=min(A[i],A[i+1])
print(ans+A[-2])
# Judge status: Accepted
K = int(input())

import queue
q = queue.Queue()

for i in range(1, 10):
    q.put(i)

cnt = 0

while True:
    n = q.get()
    cnt += 1
    if cnt == K:
        break
    if n % 10 != 0:
        q.put(n * 10 + n % 10 - 1)
    q.put(n * 10 + n % 10)
    if n % 10 != 9:
        q.put(n * 10 + n % 10 + 1)
print(n)
# Judge status: Wrong Answer
from math import ceil
N,X,T=map(int,input().split())

if X>=N:
    print(1)
else:
    print(T*ceil(N/X))
# Judge status: Wrong Answer
N = int(input())
a = list(map(int, input().split()))
b = []
for i in range(-100, 100):
	t = 0
	for j in a:
		t += (j - i) ** 2
	b.append(t)
print(min(b))
# Judge status: Accepted
s = list(input())
t = list(input())
s = sorted(s)
t = sorted(t,reverse = True)
if "".join(s) < "".join(t):
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
s = input().rstrip()

if s[2]=='B':
    s='ARC'


print(s)
# Judge status: Wrong Answer
a,b,x= map(int,input().split())
if a < x:
  if a+b >= x:
    print("YES")
  else:
    print("NO")
else:
  print("NO")
# Judge status: Accepted
X, Y = list(map(int,input().split()))
print(X + Y//2)
# Judge status: Accepted
def INT():
    return int(input())

def MI():
    return map(int, input().split())

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

from math import gcd

N = INT()
A = LI()
A.sort()
ans = A[0]

all_can_div = True

for i in range(1, N):
    A[i] = gcd(A[i], ans)
    
    if A[i] != ans and all_can_div:
        all_can_div = False

print(ans if all_can_div else min(A))
# Judge status: Accepted
a,b,c= map(int,input().split())
print("Yes" if a+b>=c else "No")
# Judge status: Wrong Answer
i = input()
N, A, B = i.split()

N = int(N)
A = int(A)
B = int(B)

if abs(A-B)%2 == 0:
  print(int(abs(A-B)/2))
else:
  e = int(min(A-1, N-B))
  d = (B-A+1) // 2
  print(e + d)
# Judge status: Accepted
k = int(input())
a, b = map(int, input().split())

if k == 1:
    print('OK')
    exit()

if k > b:
    print('NG')
    exit()

for i in range(a, b + 1):
    if i % k == 0:
        print('OK')
        exit()

print('NG')
# Judge status: Accepted
n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for _ in range(m)]

a.sort()
bc.sort(reverse=True, key=lambda x: x[1])
j = 0
for i in range(m):
    while j < len(a) and bc[i][0] > 0:
        if a[j] < bc[i][1]:
            a[j] = bc[i][1]
            bc[i][0] -= 1
        j += 1
print(sum(a))
# Judge status: Wrong Answer
l=list(map(int,input().split()))
print('YES' if l[0]+l[1]>=l[2] else 'NO')
# Judge status: Wrong Answer
n=int(input())
a=int(input())

if a%500<=n:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
import math
n, k = map(int, input().split())
print(1+math.floor(math.log(n, k)))
# Judge status: Accepted
def mapint_inp():
    return map(int, input().split())

A, B, C = mapint_inp()

ans = 0
while(1):
    if A%2==1 or B%2==1 or C%2==1:
        break
    if A == B and B == C:
        ans = -1
        break
    halvedA = A//2
    halvedB = B//2
    halvedC = C//2
    A = halvedB+halvedC
    B = halvedA+halvedC
    C = halvedA+halvedB
    ans+=1

print(ans)
# Judge status: Accepted
N = int(input()) % 10
if N in [2,4,5,7,9]:
    print('hon')
elif N in [0,1,6,8]:
    print('pon')
else:
    print('bon')
# Judge status: Accepted
s = input()
a = s.count('0')
b = s.count('1')

print(len(s)-abs(a-b))
# Judge status: Accepted
from collections import deque

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

b = deque([])

if n % 2 == 0:
    flag = True
else:
    flag = False

for i in range(n):
    if flag:
        b.append(a[i])
        flag = not flag
    else:
        b.appendleft(a[i])
        flag = not flag

print(' '.join(map(str, b)))
# Judge status: Accepted
N,K= map(int,input().split())
p = list(map(int,input().split()))
sum1=0.0
for i in range (K):
    sum1=((p[i]+1)/2.0)+sum1
sum2=sum1
for i in range(N-K):
    sum1=sum1+((p[i+K]-p[i])/2.0)
    if sum1>sum2:
        sum2=sum1
print(sum2)
# Judge status: Accepted
X = int(input())

def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    return is_prime

is_prime = sieve(2*10**5)
p = X
while is_prime[p-1] == False:
  p+=1
print(p)
# Judge status: Accepted
S = int(input())
waru = 10**9 + 7

import math
def C(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
i = 1
ans = 0
S -= 3
while S >= 0:
  ans += C(S+i-1, S)
  i += 1
  S -= 3
print(ans%waru)
# Judge status: Accepted
l = ['a', 'i', 'u', 'e', 'o']

if input() in l:
    print('vowel')
else:
    print('consonant')
# Judge status: Accepted
x = list(map(int, input().split()))
for i in range(5):
    if x[i] == 0: print(i + 1)
# Judge status: Wrong Answer
n = int(input())

if n%1000 == 0:
  print(0)
else:
  while n > 1000:
    n = n - 1000
  print(n)
# Judge status: Accepted
w,a,b=map(int,input().split())
if a+w<b:
  print(b-a-w)
elif b+w<a:
  print(a-b-w)
else:
  print(0)
# Judge status: Accepted
x,y=map(int,input().split())

a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]

for i in a:
  if x==i:
    x='a'
  if y==i:
    y='a'

for i in b:
  if x==i:
    x='b'
  if y==i:
    y='b'

for i in c:
  if x==i:
    x='c'
  if y==i:
    y='c'

if x==y:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
nb=int(input())
s = []
while nb>0:
  nb-=1
  s.append(chr(ord("a")+nb%26))
  nb//=26
roger = "".join(s)
print(roger[::-1])
# Judge status: Accepted
#! env python
# -*- coding: utf-8 -*-

import os
import sys


# ac_py.main
# Date: 2020/06/08
# Filename: main 
# Author: acto_mini

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


if __name__ == '__main__':
    main()
# Judge status: Accepted
N, A, B = map(int, input().split())
souwa = 0
for i in range(1, N+1):
    sumketa = i//10000 + ((i%10000)//1000) + ((i%1000)//100) + ((i%100)//10) + (i%10)
    if A <= sumketa <= B:
        souwa += i
print(souwa)
# Judge status: Accepted
res = 0
N, A, B = map(int, input().split())
for i in range(1, N+1):
  s = sum(map(int, str(i)))
  if A <= s <= B: res += i

print(res)
# Judge status: Accepted
import math

char = str(input())

char = char.replace('?','D')
  

print(char)
# Judge status: Wrong Answer
A, B, C = map(int, input().split())

if (A == 5) & (B == 7) & (C == 5):
    print('YES')
else:
    print('NO')
# Judge status: Accepted
import bisect
from collections import deque
n = int(input())
a = [int(input())  for _ in range(n)]
ans = deque([a[0]])
l = 1
for i in range(1,n):
    x = bisect.bisect_left(ans,a[i])
    if (x == 0):
        ans.appendleft(a[i])
        l += 1
    else:
        ans[x-1] = a[i]
print(l)
# Judge status: Wrong Answer
A, B, K = map(int, input().split())

for i in range(A, A+K):
    print(i)
for j in range(B-K+1, B+1):
    print(j)
# Judge status: Wrong Answer
N=int(input())
a=list(map(int,input().split()))
count=0
for i in range(0,2801,400):
  for j in range(N):
    if i<=a[j]<=399+i:
      count+=1
      break
c=0
for i in range(N):
  if 3200<=a[i]:
    c+=1

if c>=2:
  print(count,count+2)
elif c==1:
  print(count,count+1)
else:
  print(count,count)
# Judge status: Wrong Answer
A,B = map(int,input().split())

cnt = 0

for i in range(A,B+1):
    
    Str = str(i)
    
    if Str[:2] == Str[3:]:
        cnt += 1
        
print(cnt)
# Judge status: Accepted
# C

N, M, X = list(map(int, input().split()))
CAs = [list(map(int, input().split())) for i in range(N)]

import numpy as np
Cs = np.array([ca[0] for ca in CAs])
As = [np.array(ca[1:]) for ca in CAs]

import itertools
states = list(itertools.product([True, False], repeat=N))

def compute(state):
    arr = np.array([0] * M)
    for i in range(N):
        arr += As[i] * state[i]
    price = (Cs * state).sum() if ((arr >= X).sum() == M) else -1
    return price


res = np.array(list(map(compute, states)))
res = res[res > 0]
print(min(res) if len(res) > 0 else -1)