peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n = int(input())
paper = set()
for _ in range(n):
  a = int(input())
  if not a in paper:
    paper.add(a)
  else:
    paper.remove(a)
    
print(len(paper))
# Judge status: Accepted
M=10**9+7
n=int(input())
l=list(map(int,input().split()))
a=0
for i in range(60):
  t=sum((l[j]>>i)%2 for j in range(n))
  a+=(t*(n-t)<<i)%M
print(a%M)
# Judge status: Accepted
x, a, b = map(int, input().split())

if a >= b:
    print('delicious')
elif x >= b - a:
    print('safe')
else:
    print('dangerous')
# Judge status: Accepted
N=int(input())
a=list(map(int,input().split()))
b=[0]*N
sum=0
for i in range(N):
  b[a[i]-1]+=1

for i in range(N):
  sum+=b[i]*(b[i]-1)//2
for i in range(N):
  print(sum-b[a[i]-1]+1)
# Judge status: Accepted
a=input()
if a[2]==a[3] and a[4]==a[5]:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
n,Min,Max = map(int,input().split())
sum_min = Min * (n-1) + Max
sum_max = Max * (n-1) + Min
ans = sum_max - sum_min + 1
print(max(0,ans))
# Judge status: Wrong Answer
N = int(input())
a = list(map(int, input().split()))

four = 0
two = 0
not_four = 0

for i in range(N):
    if a[i] % 4 == 0:
        four += 1

    elif a[i] % 2 == 0 and a[i] % 4 != 0:
        two += 1
        if two == 2:
            four += 1
            two = 0
    else:
        not_four += 1

if two == 1:
    not_four += 1

while four > 0 and not_four > 0:
    four -= 1
    not_four -= 2

if four >= not_four:
    print("Yes")

else:
    print("No")
# Judge status: Wrong Answer
a,b = map(int, input().split())
if a == 0 or b == 0 or (a <= 0 and b >= 0):
    print(0)
elif a>0 and b>0:
    print("Positive")
elif (a - b)%2 == 0:
    print("Negative")
else:
    print("Positive")
# Judge status: Wrong Answer
x,k,d=map(int,input().split())
R=[]
for i in range(1,k+1):
    res=abs(x-i*d)
    R.append(res)
print(min(R))
# Judge status: Accepted
N,A,B=map(int,input().split())
if (A+B)%2==0:
	P=(B-A)//2
else:
	P=float("inf")
if (A+B)%2==1:
	Q=A
	Q+=(B-Q-(B-Q+1)//2)
else:
	Q=float("inf")

if (A+B)%2==1:
	R=N-B+1
	B=N
	A+=R
	R+=B-(A+B)//2
else:
	R=float("inf")
print(min(P,Q,R))
# Judge status: Accepted
a, b = map(int, input().split())
d = b - a - 1
print(d*(d+1)//2 - a)
# Judge status: Accepted
A, B, M = [int(n) for n in input().split()]
a  = [int(n) for n in input().split()]
b = [int(n) for n in input().split()]
ma = sorted(a)[0]
mb = sorted(b)[0]
ans = ma + mb
for m in range(M):
    x, y, c = [int(n) for n in input().split()]
    dv = a[x-1] + b[y-1] - c
    ans = min(ans , dv)
print(ans)
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
print("Yes" if b-a==c-b else "No")
# Judge status: Wrong Answer
X, Y = map(int, input().split())
MOD = 10**9+7

def mod_pow(n, m):
  res = 1
  while m > 0:
    if m & 1:
      res = (res*n)%MOD
    n = (n*n)%MOD
    m >>= 1
  return res
  
if (2*Y-X)%3 != 0 or (2*X-Y)%3 != 0:
  print(0)
else:
  A = (2*X-Y)//3
  B = (2*Y-X)//3
  m = 1
  n = 1
  for i in range(A):
    m = (m*(A+B-i))%MOD
    n = (n*(A-i))%MOD
  inverse_n = mod_pow(n, MOD-2)
  print((m*inverse_n)%MOD)
# Judge status: Accepted
N,M=map(int,input().split())
sc=[]
for i in range(M):
  sc.append(list(map(int,input().split())))

ans=-1
cnt=10**(N-1)
if cnt==1:cnt-=1
while True:
  if len(str(cnt))>N:break
  if len(str(cnt))!=N:continue
  ret=True
  for i in range(M):
    if str(cnt)[sc[i][0]-1]!=str(sc[i][1]):
      ret=False
      break
  if ret:
    ans=cnt
    break
  cnt+=1
print(ans)
# Judge status: Wrong Answer
def resolve():
    n = int(input())
    S0 = sorted(list(input()))
    dic = dict(zip(set(S0), [0]*len(set(S0))))
    for s0 in S0:
        dic[s0] += 1

    for i in range(n-1):
        S = list(input())
        for k, v in dic.items():
            cnt = S.count(k)
            dic[k] = min(v, cnt)

    ans = ''
    for k, v in dic.items():
        ans += k * v
    print(ans)

if __name__ == '__main__':
    resolve()
# Judge status: Accepted
N,C,K=map(int,input().split())
T=sorted([int(input()) for i in range(N)])
cnt=0
i=0
while(i<N):
    j=i
    lim=T[i]+K
    while(j<N and T[j]<=lim and j-i+1<=C):
        j+=1
    cnt+=1
    i=j
print(cnt)
# Judge status: Accepted
s = input()
t = input()
ans = len(t)
for i in range(len(s)-len(t)+1):
    temp = 0
    for j in range(0,len(t)):
        if s[i+j]==t[j]:
            temp += 1
    ans = min(ans,len(t)-temp)
print(ans)
# Judge status: Wrong Answer
import math

a, b, H, M = map(int, input().split())
a_ = 360 / 12
b_ = 360 / 60
a_x = a * math.sin(math.radians(a_ * H))
a_y = a * math.cos(math.radians(a_ * H))
b_x = b * math.sin(math.radians(b_ * M))
b_y = b * math.cos(math.radians(b_ * M))

print(math.sqrt((b_x - a_x) ** 2 + (b_y - a_y) ** 2))
# Judge status: Accepted
S,T = map(str,input().split())
print(T,S,sep='')
# Judge status: Accepted
N = int(input())

if N<10:
  print(N)
elif 10<=N and N<100:
  print(9)
elif 100<=N and N<1000:
  print(9 + (N-100+1))
elif 1000<=N and N<10000:
  print(909)
elif 10000<=N and N<100000:
  print(909 + (N-10000+1))
else:
  print(90909)
# Judge status: Accepted
#!/usr/bin/env python3

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

if a+b >= c:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a,b = map(int, input().split())
n = b-a
print(n*(n+1)//2-b)
# Judge status: Wrong Answer
# coding: utf-8
n, x = map(int,input().split())
A = list(map(int,input().split()))
ans=0
for i in range(n-1):
    s = A[i] + A[i+1]
    if s-x >= 0:
        ans += s-x
        A[i+1] -= s-x
print(ans)
# Judge status: Accepted
N = int(input())
X = list(map(int, input().split()))
sort_X = sorted(X)
L = sort_X[(N//2)-1]
R = sort_X[N//2]
for i in range(N):
    if X[i] <= L:
        print(R)
    else:
        print(L)
# Judge status: Wrong Answer
print("pink" if int(input())>=3200 else "red")
# Judge status: Wrong Answer
import sys

N, K = map(int, input().split())
Ds = list(input())

for i in range(N, 1000000):
    for j in range(K):
        if Ds[j] in str(i):
            break
        if j == K-1:
            print(i)
            sys.exit(0)
# Judge status: Wrong Answer
n = int(input())
a = [x-(i+1) for i, x in enumerate(list(map(int, input().split())))]


b1 = sum(a)//len(a)


def ceil(a, b):
    return -(-a // b)


b2 = ceil(sum(a), len(a))
ans1 = 0
ans2 = 0

for aa in a:
    ans1 += abs(aa-b1)
    ans2 += abs(aa-b2)
print(min(ans1, ans2))
# Judge status: Wrong Answer
N = list(input())
M = list(input())
count =0
for i in range(len(N)):
  
  a = M.pop(0)
  M.append(a)
  if M == N:
    count +=1
if count == 1:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n = int(input())

if n != 0:
	ans = []
	while n != 0:
		ans.append(abs(n % -2))

		n += n % -2
		n /= -2
		n = int(n)

	print(''.join([str(i) for i in reversed(ans)]))
else:
	print(0)
# Judge status: Accepted
X,K,D=map(int,input().split())

X=abs(X)

q=X//D
r=X%D

if r < D-r:
    n=q
    ans1=r
    ans2=D-r
else:
    n=q+1
    ans1=D-r
    ans2=r

if K <= n:
    ans=X-K*D
    ans=abs(ans)
else:
    d=K-n
    if d%2==0:
        ans = ans1
    else:
        ans = ans2
print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
dic = {}
for a in A:
  if a in dic:
    dic[a] += 1
  else:
    dic[a] = 1
l = []
for k, v in dic.items():
  if v >= 2:
    l.append(k)
l.sort()
if len(l) == 0:
  print(0)
elif len(l) == 1:
  if dic[l[-1]] >= 4:
    print(l[-1] ** 2)
  else:
    print(0)
else:
  if dic[l[-1]] >= 4:
    print(l[-1] ** 2)
  else:
    print(l[-1] * l[-2])
# Judge status: Wrong Answer
a1, a2, a3 = map(int, input().split())
print('burst' if a1 + a2 + a3 >= 22 else 'win')
# Judge status: Wrong Answer
a,b,c = map(int,input().split())
if a == b and a == c:
    print("No")
else:
    print("Yes")
# Judge status: Accepted
n=int(input())
p=list(map(int,input().split()))

cnt=0
for i in range(1,n-1):
    if (p[i-1]<p[i]<p[i+1] or p[i+1]<p[i]<p[i-1]):
        cnt+=1
print(cnt)
# Judge status: Accepted
K = int(input())
ans = [1, 2, 3, 4, 5, 6, 7, 8, 9]

for i in ans:
    if len(ans) > K:
        break
    if i%10 == 0:
        ans.append(i*10+i%10)
        ans.append(i*10+i%10+1)
    elif i%10 == 9:
        ans.append(i*10+i%10-1)
        ans.append(i*10+i%10)
    else:
        ans.append(i*10+i%10-1)
        ans.append(i*10+i%10)
        ans.append(i*10+i%10+1)
    
print(ans[K-1])
# Judge status: Accepted
import sys
n=int(input())
an=[0]*(n+1)
for i in range(n):
  an[i+1]=int(input())

t=1
cnt=0
for _ in range(n*2):
  t=an[t]
  cnt+=1
  if t==2:
    print(cnt)
    sys.exit()
print(-1)
# Judge status: Wrong Answer
X, K, D = map(int, input().split())

k = K - (X // D)
x = X % D
while True:
    if abs(x) < D:
        if k % 2 == 0:
            print(abs(x))
        else:
            print(D-abs(x))
        exit()

    x = abs(x - D)
    k -= 1
    if k == 0:
        print(x)
        exit()
# Judge status: Accepted
n = int(input())
m = int(n ** 0.5 + 3)
for i in range(m):
    if i ** 2 > n:
        print((i - 1) ** 2)
        break
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,m=map(int,input().split())
    C=[tuple(map(int,input().split())) for i in range(n)]
    C.sort()
    honsu=m
    cost=0
    for i,c in enumerate(C):
        cost+=c[0]*min(honsu,c[1])
        honsu-=c[1]
        if honsu<=0:
            break
    print(cost)
if __name__=='__main__':
    main()
# Judge status: Accepted
A, B, C, X = [int(input()) for i in range(4)]
print(sum([500*a+100*b+50*c == X for a in range(A+1) for b in range(B+1) for c in range(C+1)]))
# Judge status: Accepted
N=int(input());n=0;print([2**i for i in range(N) if 2**i<=N][-1])
# Judge status: Wrong Answer
s=str(input())
s=list(s)
for i in range(0,len(s)):
  if s[i]=="A":
    temp1=i
    break    
for j in range(temp1+1,len(s)):
  if s[j]=="Z":
    temp2=j
    break 
print(temp2-temp1+1)
# Judge status: Accepted
n = int(input())
L = []
j = 0
for i in range(n):
    s = list(bin(i+1)[2:])[::-1]
    cnt = 0
    while j <=n-1:
        if s[j] == "0":
            cnt +=1
            j +=1
            #print(j,cnt)
        elif s[j] == "1":
            L.append((cnt,i+1))
            cnt=0
            break
    j =0
print(max(L)[1])
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
af=[]
al=[]
for i in range(n):
    if i%2==0:
        af.append(a[i])
    else:
        al.append(a[i])

if n%2==0:
    al=al[::-1]
    for a in al:
        print(a,end=" ")
    for a in af:
        print(a,end=" ")
else:
    af=af[::-1]
    for a in af:
        print(a,end=" ")
    for a in al:
        print(a,end=" ")
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
j = 0
for i in A:
    if i % 2 == 0:
        if i % 3 == 0 or i % 5 == 0:
            pass
        else:
            j += 1
    else:
        pass
if j > 0:
    print('DENIED')
else:
    print('APPROVED')
# Judge status: Accepted
x, y = map(int, input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c =[2]
if x in a and y in a:
  print("Yes")
elif x in b and y in b:
  print("Yes")
elif x in c and y in c:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
# -*- coding: utf-8 -*-
"""
Created on Sat May  9 16:09:21 2020

@author: shinba
"""

import fractions

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

print(int(a*b/fractions.gcd(a,b)))
# Judge status: Wrong Answer
s = input()
n = len(s)
a = 0
for i in range(n-2):
  if abs(753-a)>abs(753-int(s[i:i+3])):
    a = int(s[i:i+3])
print(753-a)
# Judge status: Accepted
n=int(input())
nlst=[input() for i in range(n)]
m=int(input())
mlst=[input() for i in range(m)]
ans=0
for i in nlst:
    plus=nlst.count(i)
    minus=mlst.count(i)
    ans=max(ans,plus-minus)
    
print(ans)
# Judge status: Accepted
U=str(input())

l=len(U)
print("x"*l)
# Judge status: Wrong Answer
def main():
    n = int(input())
    result = True
    used = {' ':0}
    for order in range(0,n):
        word = str(input())
        print(sorted(used.keys())[len(used) -1])
        if word in used or sorted(used.keys())[len(used) -1][-1] == word[0]:
            print('NO')
            result = False
            break
        else:
            used.setdefault(word,0)
    if result:
        print('Yes')
 
 
if __name__ == "__main__":
    main()
# Judge status: Accepted
n,m = map(int,input().split())
gate_list = [ list(map(int,input().split())) for i in range(m)]
#print(gate_list)
ans1 = gate_list[0][0]
ans2 = gate_list[0][1]
for i in range(1,m):
    ans1 = max(ans1,gate_list[i][0])
for i in range(1,m):
    ans2 = min(ans2,gate_list[i][1])
ans = ans2 - ans1
if ans < 0:
    print(0)
else:
    print(ans+1)
# Judge status: Accepted
N, K = map(int, input().split())
S = list(input())
S[K-1] = chr(ord(S[K-1])+32)
print("".join(S))
# Judge status: Accepted
import sys
readline = sys.stdin.readline

N,K = map(int,readline().split())

AB = [list(map(int,readline().split())) for i in range(N)]

AB = sorted(AB, key = lambda x:x[0])
amount = 0
for a,b in AB:
  amount += b
  if amount >= K:
    print(a)
    break
# Judge status: Wrong Answer
s=list(input())
ss=list(set(s))
print('Good' if len(s)==len(ss) else 'Bad')
# Judge status: Wrong Answer
from fractions import gcd


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

B = [0] * (N + 1)
B[0] = next(A)
B[1] = next(A)
B[2] = B[0]
B[0] = gcd(B[0], B[1])

for i, a in enumerate(A):
    i += 3
    B[i] = gcd(B[0], a)
    for j in range(i):
        B[j] = gcd(B[j], a)

print(max(B))
# Judge status: Accepted
n = int(input())

res = 0
for a in range(1, n+1):
    for b in range(1, int((n+1)/a)+1):
        c = n-a*b
        if c>0 and a*b+c==n:
            res+=1
print(res)
# Judge status: Wrong Answer
a,b = map(int,input().split())

num = int(str(a)+str(b))
ans = 'No'

for i in range(1,101):
    if num == i**2:
        ans = 'Yes'
        break
        
print(ans)
# Judge status: Accepted
N=int(input())
S=input()
x = 0
ans = x
for c in S:
    if c == 'I':
        x += 1
    elif c == 'D':
        x -= 1

    if x > ans:
        ans = x

print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
B = [0] * N #部下の人数

for a in A:
    B[a-1] += 1

for b in B:
    print(b)
# Judge status: Accepted
S = input()
P =2019
ans = 0

count = [0] * P
count[0] = 1
u = 0
for i, s in enumerate(reversed(S)):
    u = (int(s) * pow(10, i, P) + u) % P
    ans += count[u]
    count[u] += 1
print(ans)
# Judge status: Wrong Answer
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
for i in range(m):
  b,c=map(int,input().split())
  for j in range(b):
    if a[j]<c:
      a[j]=c
    else:
      break
  if j>0:
    a.sort()
print(sum(a))
# Judge status: Accepted
import sys
import fractions
import math
import itertools

a,b=list(map(int,input().split()))
ans=0

if a>=b:
	ans+=a
	a-=1
else:
	ans+=b
	b-=1	
if a>=b:
	ans+=a
	a-=1
else:
	ans+=b
	b-=1	
print(ans)
# Judge status: Wrong Answer
import copy
import math

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

ub = 10**9
lb = 0

while ub - lb > 0.01:
    x = (ub + lb) / 2
    cnt = 0
    for i in a:
        cnt += math.ceil(i/x)
    if cnt <= n+k:
        ub = copy.deepcopy(x)
    else:
        lb = copy.deepcopy(x)
ans = round(ub, 1)
print(math.ceil(ans))
# Judge status: Wrong Answer
n = input()
for letter in n:
    if letter == '7':
        result = "Yes"
    else:
        result = 'No'
print(result)
# Judge status: Accepted
N = int(input())
A = [int(input()) for i in range(N)]

ans = 0
tmp = 0
for a in A:
    if a == 0:
        tmp = 0
    a += tmp
    ans += a // 2
    tmp = a % 2

print(ans)
# Judge status: Accepted
a,b,c=map(int, input().split())
print("Yes" if a<=c<=b else "No")
# Judge status: Accepted
# -*- coding: utf-8 -*-
"""
Created on Sun Jul  5 21:05:16 2020

@author: asaka
"""

N = int(input())
ans = [0]*4

for n in range(N):
    h = input()
    if h == "AC":
        ans[0] += 1
    elif h == "WA":
        ans[1] += 1
    elif h == "TLE":
        ans[2] += 1
    elif h == "RE":
        ans[3] += 1
        
print("AC x ", ans[0])
print("WA x ", ans[1])
print("TLE x ", ans[2])
print("RE x ", ans[3])
# Judge status: Accepted
S=input()
tmp = list(S)[-1]

if tmp=="s":
    print(S+"es")
else:
    print(S+"s")
# Judge status: Accepted
n = int(input())

ans = 0
for a in range(1, n):
    for b in range(1, n //a + 1):
        if a * b < n:
            ans += 1

print(ans)
# Judge status: Wrong Answer
import itertools
N = int(input())
L = list(map(int,input().split(" ")))
S = set(L)
X = []


if len(S) < 3:
    print(0)
else:
    for i in S:
        if L.count(i) > 1:
             X.append(L.count(i))
            
    ans = len(list(itertools.combinations(S, 3)))
    for i in X:
        ans *= i
    print(ans)
# Judge status: Wrong Answer
from math import ceil
N,H=map(int, input().split())

A=[0]*N
B=[0]*N
for i in range(N):
    a,b=map(int, input().split())
    A[i]=a
    B[i]=b

A=sorted(A)
B=sorted(B, reverse=True)
amax=max(A)

ans=0

for i in range(N):
    b=B[i]
    if b>amax:
        H-=b
        ans+=1
    else:
        break
if H>0:
    ans+=ceil(H/amax)
print(ans)
# Judge status: Accepted
s = input(); t= input()
if(s == t[0:-1] and len(s)+1==len(t)):
  print("Yes")
else:
  print("No")
# Judge status: Accepted
import itertools

N = int(input())

nine_list = [9**i for i in range(0, 6)]
six_list = [6**i for i in range(1, 7)]

ans = float("inf")
for combi in itertools.product([i for i in range(6)], repeat=6):
    # print(combi)
    count = sum(combi)
    six_sum = sum([a*b for a, b in zip(six_list, combi)])
    if N < six_sum:
        continue
    rest = N - six_sum
    for nine in reversed(nine_list):
        if nine > rest:
            continue
        count += rest // nine
        rest = rest % nine
    ans = min(ans, count)

print(ans)
# Judge status: Wrong Answer
n, T = map(int, input().split())
cost = []
time = []
ans = 1000

for i in range(n):
    c, t = map(int, input().split())
    cost.append(c)
    time.append(t)

for c, t in zip(cost, time):
    if t <= T and ans > c:
        ans = c

print(ans if ans != 1000 else 'TLE')
# Judge status: Wrong Answer
#https://atcoder.jp/contests/abc174/tasks/abc174_a

N= []
N= int(input(" "))

if N >=30:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
def main():
    x, y = map(int, input().split())
    cnt = 1

    while True:
        x *= 2
        if x <= y:
            cnt += 1
        else:
            break

    print(cnt)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
import heapq
import math

def LI():
  return [int(s) for s in input().split()]

N,M = LI()
a = LI()
a = list(map(lambda x: x*(-1), a))  # 各要素を-1倍

heapq.heapify(a)

for i in range(M):
    x = (-1)*(abs(heapq.heappop(a))//2)
    print(x)
    heapq.heappush(a,x)

cost = 0
for i in range(N):
  x = heapq.heappop(a)
  cost+=abs(x)
  
print(cost)
# Judge status: Accepted
n, h = map(int, input().split())
li = list(map(int, input().split()))
li_a = [[0] for i in range(n)]
for i in range(h):
  a, b = map(int, input().split())
  li_a[a-1].append(li[b-1])
  li_a[b-1].append(li[a-1])
ans = 0
for j in range(n):
  if li[j] > max(li_a[j]):
    ans += 1
print(ans)
# Judge status: Wrong Answer
a,b,k=map(int,input().split())
if k*2>b:
    for i in range(a,b+1):
        if i<a+k:
            print(i)
        elif b-k<i:
            print(i)
else:
    for i in range(a,min(a+k,b+1)):
        print(i)
    for i in range(max(a,b-k+1),b+1):
        print(i)
# Judge status: Accepted
import fractions
N = int(input())
T = [int(input()) for i in range(N)]
 
ans = T[0]
for i in range(N-1):
    ans = ans * T[i+1]//fractions.gcd(ans, T[i+1])
print(ans)
# Judge status: Accepted
S=input()
slist={"SUN":7,"MON":6,"TUE":5,"WED":4,"THU":3,"FRI":2,"SAT":1}
print(slist[S])
# Judge status: Wrong Answer
x = int(input())
if x <= 599:
    print(8)
    exit()
x -= 599
for i in range(9):
    x -= 199
    if x <= 0:
        print(7 - i)
        exit()
# Judge status: Wrong Answer
s=int(input())
a=[]
na=[]
a.append(s)
for i in range(1,10**6):
    if a[i-1]%2==0:
        a.append(a[i-1]/2)
    else:
        a.append(a[i-1]*3+1)
    na=set(a)
    if len(na)!=i+1:
        print(a[i])
        exit()
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
count=0
for i in range(n):
    if a[i]!=i+1-count:
        count=count+1
print(count)
# Judge status: Accepted
a, b, c = map(int, input().split())
print(min([a+b, a+c, b+c]))
# Judge status: Wrong Answer
a,v = map(int, input().split())
b,w = map(int, input().split())
t = int(input())

distance = b - a
speed_remainder = v - w

if distance <= 0:
    print("NO")
elif distance <= t * speed_remainder:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
nums=list(map(int, input().split()))
nums.sort()
print(nums[0]+nums[1])
# Judge status: Wrong Answer
x=int(input())
ans=0
for i in range(100000000000):
  if (i+1)%2==1:
    x-=5
    ans+=1
    if x<=0:
      print(ans)
      break
  else:
    x-=6
    if x<=0:
      print(ans)
      break
# Judge status: Wrong Answer
from itertools import accumulate

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

count = 0
ironbar = list(accumulate(A))

i = 0
j = len(A) - 1

while i + 1 < j:
    left = ironbar[i]
    right = ironbar[-1] - ironbar[i]
    if right <= left:
        j = (i+j) // 2
    else:
        i = (i+j) // 2

# iかjが正解
i_bar = abs(ironbar[i] - (ironbar[-1] - ironbar[i]))
j_bar = abs(ironbar[j] - (ironbar[-1] - ironbar[j]))

print(min(i_bar, j_bar))
# Judge status: Wrong Answer
N = int(input())
XY = [[0]*2]*N
dis = 0
for i in range(N):
  XY[i] = [int(_) for _ in input().split()]
for i in range(N):
  Xi = XY[i][0]
  Yi = XY[i][1]
  for j in range(i+1,N):
    Xj = XY[j][0]
    Yj = XY[j][1]
    dis += ((Xi-Xj)**2 + (Yi-Yj)**2)**0.5
_N = 1
for n in range(N,0,-1):
  _N *= n
print(dis/_N)
# Judge status: Accepted
N,X = map(int,input().split())
x = list(map(int,input().split()))
x = sorted([abs(i-X) for i in x])

y = x[0]
for  i in range(1,N):
    z = x[i]
    y,z = max(y,z),min(y,z)
    while z!=0:
        y,z = z,y%z
print(y)
# Judge status: Accepted
n=int(input())
l=[0]*(10000+1)
l[0]=1
for i in range(n):
  s=int(input())
  for j in range(10000,s-1,-1):
    if l[j-s]:l[j]=1
for j in range(10000,-1,-1):
  if j%10 and l[j]:print(j);exit()
print(0)
# Judge status: Wrong Answer
N = int(input())
X = input()
L = len([i for i in X if i != "("])
R = len(X) - L
mL = 0
for i in X:
  if i == ")":
    mL += 1
  else:
    break
mR = 0
for i in X[::-1]:
  if i == "(":
    mR += 1
  else:
    break
#print(L, R, mL, mR)
result = ""
if L >= R:
  result += "(" * max([L-R, mL])
result += X
if R >= L:
  result += ")" * max([R-L, mR])
print(result)
# Judge status: Accepted
H,A=map(int,input().split())
ans=0
while H>0:
    H=H-A
    ans+=1
print(ans)
# Judge status: Accepted
a, b, c, d = map(int, input().split())
answer = max(a*c, a*d, b*c, b*d)
print(answer)
# Judge status: Accepted
s = input()
l = "keyence"
if s[0:7] == l:
    print("YES")
elif s[-7:] == l:
    print("YES")
else:
    for i in range(7):
        if s[:i+1] == l[:i+1] and s[i-6:] == l[i+1:]:
            print("YES")
            exit()
    print("NO")
# Judge status: Accepted
import sys
input = sys.stdin.readline


N=int(input())

ANS=[0]*(10**5+1)

for x in range(1,10**2+1):
    for y in range(1,10**2+1):
        for z in range(1,10**2+1):
            ANS[x*x+y*y+z*z+x*y+y*z+z*x]+=1

print(*ANS[1:N+1])
# Judge status: Wrong Answer
a,b,c = map(int,input().split())
print("YES" if a + (b-c) == c else "NO")
# Judge status: Accepted
n =int(input())
ans = n * (n - 1) // 2
print(ans)
# Judge status: Accepted
a,b = map(int,input().split())
c = -1
if a < 10:
    if b < 10:
        c = a*b
print(c)
# Judge status: Wrong Answer
M=[]
for i in range(1001):
   m=(i+1)/2
   M.append(m) 

N,K=map(int,input().split())
P=list(map(int,input().split()))
S=[]
s=0
for i in range(N):
    a=P[i]
    s=s+M[a]
    S.append(s)
Q=[]
Q.append(S[0])
q=0
for i in range(N-K):
    q=S[i+K]-S[i] 
    Q.append(q)
    q=0
print(max(Q))
# Judge status: Wrong Answer
a, b = map(int, input().split())

if a == b:
  print('Draw')
elif a < b:
  print('Bob')
else:
  print('Alice')
# Judge status: Wrong Answer
a,b,c,k=map(int,input().split())
print(a-max(k-a-b,0))
# Judge status: Wrong Answer
n = input().split(" ")
a = input().split(" ")
n[0] = int(n[0])
sum_HomeworkDays = 0

for i in a:
	sum_HomeworkDays += int(i)
    
if n[0]-sum_HomeworkDays > 0:
  print(n[0]-sum_HomeworkDays)
else:
  print("-1")