Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
happiness = 0

for i in range(0, N, 1):
  if i > 0:
    if A[i-1] == (A[i]-1):
      happiness += (B[A[i]]+C[i-1])
  else:
    happiness += B[A[i]-1]
print(happiness)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
happiness = 0

for i in range(0, N, 1):
  if i > 0:
    if A[i-1] == (A[i]-1):
      happiness += (B[A[i]-1]+C[A[i]-2])
    else:
      happiness += B[A[i]-1]
  else:
    happiness += B[A[i]-1]
print(happiness)

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
happiness = 0

for i in range(0, N, i++):
  if(A[N-1]==A[N]-1):
    happiness += (B[A[N]]+C[N-1])
  else:
    happiness += B[A[N]]
print(happiness)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
happiness = 0

for i in range(0, N, 1):
  if i > 0:
    if A[i-1] == (A[i]-1):
      happiness += (B[A[i]-1]+C[A[i]-2])
    else:
      happiness += B[A[i]-1]
  else:
    happiness += B[A[i]-1]
print(happiness)

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
happiness = 0

for i in range(0, N, i++):
  if(A[N-1]==A[N]-1):
    happiness += (B[A[N]]+C[N-1])
  else:
    happiness += B[A[N]]

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
happiness = 0

for i in range(0, N, 1):
  if i > 0:
    if A[i-1] == (A[i]-1):
      happiness += (B[A[i]-1]+C[A[i]-2])
    else:
      happiness += B[A[i]-1]
  else:
    happiness += B[A[i]-1]
print(happiness)
Buggy python submission (verdict: Runtime Error):
s = input().split()
a, b = s[0], s[1]
x = [a+b, a-b, a*b]
print(max(x))

Fixed submission:
s = input().split()
a, b = int(s[0]), int(s[1])
x = [a+b, a-b, a*b]
print(max(x))
Buggy python submission (verdict: Runtime Error):
class Main:
    import math
    H = int(input())
    if H == 1:
        print(1)
    else:
        cnt = int(math.log(H, 2))
        num = 0
        for i in range(cnt+1):
            num += 2 ** i
    print(num)

Fixed submission:
class Main:
    s = list(map(int, input().split()))
    h = s[0]
    a = s[1]
    cnt = 0
    if h >= a:
        while h > 0:
            h -= a
            cnt += 1

    else:
        cnt = 1
    print(cnt)

Buggy python submission (verdict: Runtime Error):
class Main:
    import math
    H = int(input())
    if H == 1:
        print(1)
    else:
        cnt = int(math.log(H, 2))
        num = 0
        for i in range(cnt+1):
            num += 2 ** i
            print(num)


Fixed submission:
class Main:
    s = list(map(int, input().split()))
    h = s[0]
    a = s[1]
    cnt = 0
    if h >= a:
        while h > 0:
            h -= a
            cnt += 1

    else:
        cnt = 1
    print(cnt)
Buggy python submission (verdict: Runtime Error):
class Main:
    s = list(map(int, input().split()))
    n = s[0]
    k = s[1]
    sum = 0
    ksum=0
    list = [int(i) for i in input().split()]
    list = sorted(1, reverse=True)
    list[:k]
    for num in list:
        sum += num
    for knum in list[:k]:
        ksum += knum
    print(sum-ksum)

Fixed submission:
class Main:
    s = list(map(int, input().split()))
    n = s[0]
    k = s[1]
    sum = 0
    kSum = 0
    list = [int(i) for i in input().split()]
    newList = sorted(list, reverse=True)
    list[:k]
    for num in newList:
        sum += num
    for kNum in newList[:k]:
        kSum += kNum
    print(sum-kSum)
Buggy python submission (verdict: Runtime Error):
import numpy as np

s = input().split()
H = int(s[0])
N = int(s[1])

m = np.array([list(map(int, input().split())) for i in range(N)])
A = m[:, 0]
B = m[:, 1]

def func(H, m):
    A = m[:, 0]
    B = m[:, 1]

    if H < A[i]:
        i = np.argmin((H // A) * B)
        return (H // A[i]) * B[i]
    else:
        i = np.argmax(A / B)
        H_next = H - (H // A[i]) * B[i] 
        return (H // A[i]) * B[i] + func(H_next)
        
        func(H_next, )
        j = np.argmin(B)
        print((H // A[i])*B[i] + B[j])

print(func(H, m))

Fixed submission:
s = input().split()
H = int(s[0])
A = int(s[1])

ans = H // A
if H % A:
    print(ans+1)
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
s = input().split()
H = int(s[0])
N = int(s[1])

A = input().split()

if len(A) != N:
    print('error')
else:
    if sum(A) >= H:
        print('Yes')
    else:
        print('No')


Fixed submission:
s = input().split()
H = int(s[0])
N = int(s[1])

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

if sum(A) >= H:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
s = input().split()
N = int(s[0])
K = int(s[1])

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

H_s = sorted(H, reverse=True)
H_s[:N] = 0

print(sum(H_s))


Fixed submission:
s = input().split()
N = int(s[0])
K = int(s[1])

H = list(map(int, input().split()))
H_s = sorted(H, reverse=True)

print(sum(H_s[K:]))

Buggy python submission (verdict: Runtime Error):
s = input().split()
N = int(s[0])
K = int(s[1])

H = input().split()

H_s = sorted(H, reverse=True)
H_s[:N] = 0

print(sum(H_s))


Fixed submission:
s = input().split()
N = int(s[0])
K = int(s[1])

H = list(map(int, input().split()))
H_s = sorted(H, reverse=True)

print(sum(H_s[K:]))
Buggy python submission (verdict: Time Limit Exceeded):
H, N = map(int, input().split())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

mA = max(A)

INF = 1001001001
DP = [INF for _ in range(H+1)]
DP[0] = 0
ans = INF
for h in range(H):
    for j in range(N):
        DP[min(h+A[j], H)] = min(DP[min(h+A[j], H)], DP[h] + B[j])
    if DP[H] < ans:
        ans = DP[H]

print(ans)

Fixed submission:
H, N = map(int, input().split())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

mA = max(A)

INF = 1001001001
DP = [INF for _ in range(H+1)]
DP[0] = 0
for h in range(H):
    for j in range(N):
        nh = min(h+A[j], H)
        DP[nh] = min(DP[nh], DP[h] + B[j])

print(DP[H])
Buggy python submission (verdict: Runtime Error):
n = int(input())
v = list(map(int, input().split()))
 
for i in range(n-1):
	mn1 = v.remove(min(v))
	mn2 = v.remove(min(v))
	v.append((mn1 + mn2) / 2)
 
print(v[0])


Fixed submission:
n = int(input())
v = list(map(int, input().split()))
 
for i in range(n-1):
  mn1 = min(v)
  v.remove(min(v))
  mn2 = min(v)
  v.remove(min(v))
  v.append((mn1 + mn2) / 2.0)
 
print(v[0])

Buggy python submission (verdict: Runtime Error):
n = int(input())
v = list(map(int, input().split()))
 
for i in range(n-1):
	mn1 = v.remove(min(v))
    mn2 = v.remove(min(v))
    v.append((mn1 + mn2) / 2)
 
print(v[0])

Fixed submission:
n = int(input())
v = list(map(int, input().split()))
 
for i in range(n-1):
  mn1 = min(v)
  v.remove(min(v))
  mn2 = min(v)
  v.remove(min(v))
  v.append((mn1 + mn2) / 2.0)
 
print(v[0])

Buggy python submission (verdict: Runtime Error):
n = int(input())
v = map(int, input().split())

for i in range(n-1):
	mn1 = v.remove(min(v))
    mn2 = v.remove(min(v))
    v.append((mn1 + mn2) / 2)

print(v[0])


Fixed submission:
n = int(input())
v = list(map(int, input().split()))
 
for i in range(n-1):
  mn1 = min(v)
  v.remove(min(v))
  mn2 = min(v)
  v.remove(min(v))
  v.append((mn1 + mn2) / 2.0)
 
print(v[0])
Buggy python submission (verdict: Runtime Error):
n, q = map(int, input().split())

childs = [[] for _ in range(n+1)]
parent = [-1 if i == 1 else None for i in range(n+1)]
nodes_in_level = [[] for _ in range(n+1)]
level_of_node = [0 if i == 1 else None for i in range(n+1)]

level_of_node[0].append(1)

for _ in range(n-1):
  a, b = map(int, input().split())
  childs[a].append(b)
  parent[b] = a
  level_of_node[b] = level_of_node[a] + 1
  nodes_in_level[level_of_node[b]].append(b)

ans = 0
nodes_under_level = [0 for i in range(n+1)]
for i in list(range(n))[::-1]:
  nodes_under_level[i] = nodes_under_level[i+1] + len(nodes_in_level[i])

for _ in range(q):
  p, x = map(int, input().split())
  ans += nodes_under_level[level_of_node[p]] * x
  
print(ans)
  

Fixed submission:
n, q = map(int, input().split())

childs = [[] for _ in range(n+1)]
parent = [-1 if i == 1 else None for i in range(n+1)]
plus = [0 for i in range(n+1)]

for _ in range(n-1):
  a, b = map(int, input().split())
  childs[a].append(b)
  parent[b] = a

for _ in range(q):
  p, x = map(int, input().split())
  plus[p] += x
  
nodes = [1]
while nodes:
  node = nodes.pop()
  if childs[node]:
    for cn in childs[node]:
      plus[cn] += plus[node]
      nodes.append(cn)

print(' '.join([str(num) for num in plus[1:n+1]]))
Buggy python submission (verdict: Time Limit Exceeded):
mod = 1000000007
n = int(input())
s = input()
abets ="abcdefghijklmnopqrstuvwxyz"
counts = []
for c in abets:
  counts.append(s.count(c))
ans =-1
for ptn in range(2** len(abets)):
  bin_str = format(ptn,'b')
  subans = 1
  for i, b in enumerate(bin_str[::-1]):
    if b =='1':
      subans = (subans * counts[i]) % mod
  ans = (ans + subans) % mod
print(ans)

Fixed submission:
mod = 1000000007
n = int(input())
s = input()
abets ="abcdefghijklmnopqrstuvwxyz"
counts = []
for c in abets:
  counts.append(s.count(c))
ans = 0
for cnt in counts:
  if cnt != 0:
    ans = (ans + ans*cnt + cnt) % mod
print(ans)

Buggy python submission (verdict: Runtime Error):
mod = 1000000007
n = int(input())
s = input()
abets = “abcdefghijklmnopqrstuvwxyz”
counts = []
for c in abets:
  counts.append(s.count(c))
ans = 0
for ptn in range(2** len(abets)):
  bin_str = format(ptn, ‘b’)
  subans = 1
  for i, b in enumerate(bin_str[::-1]):
    if b == ‘1’:
      subans = (subans * counts[i]) % mod
  ans = (ans + subans) % mod
print(ans)

Fixed submission:
mod = 1000000007
n = int(input())
s = input()
abets ="abcdefghijklmnopqrstuvwxyz"
counts = []
for c in abets:
  counts.append(s.count(c))
ans = 0
for cnt in counts:
  if cnt != 0:
    ans = (ans + ans*cnt + cnt) % mod
print(ans)
Buggy python submission (verdict: Runtime Error):
# gcd
def gcd(a, b):
	return gcd(b, a % b) if b != 0 else a

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

max_gcd = L[0]

for i in range(1, N):
    max_gcd = gcd(max_gcd, L[i])

print(max_gcd)


Fixed submission:
# gcd
def gcd(a, b):
	return gcd(b, a % b) if b != 0 else a

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

max_gcd = L[0]

for i in range(1, N):
    max_gcd = gcd(max_gcd, L[i])

print(max_gcd)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import sys

N, M = list(map(int, input().split()))
if M == 0:
  h = []
else:
  h = np.array(sys.stdin.readlines()).flatten().astype(int)

if N==1:
  print(1)
elif N==2:
  if M==1:
    print(1)
  else:
    print(2)
else:
  DP = np.zeros(N+1)
  DP[0] = 1
  if 1 in h:
    DP[1] = -1
  else:
    DP[1] = 1
  for i in range(2,N+1):
    if DP[i-2]<0 and DP[i-1]<0:
      print(0)
      exit()
    if i in h:
      DP[i] = -1
    else:
      if DP[i-1]>=0:
        DP[i] += DP[i-1]
      if DP[i-2]>=0:
        DP[i] += DP[i-2]
      DP[i] = DP[i] % 1000000007
  print(int(DP[N]))

Fixed submission:
import sys

N, M = list(map(int, input().split()))
if M == 0:
  h = []
else:
  h = sys.stdin.readlines()
  h = set(map(int, list(set(h))))

if N==1:
  print(1)
elif N==2:
  if M==1:
    print(1)
  else:
    print(2)
else:
  DP = []
  DP.append(1)
  if 1 in h:
    DP.append(-1)
  else:
    DP.append(1)
  for i in range(2,N+1):
    if DP[i-2]<0 and DP[i-1]<0:
      print(0)
      exit()
    DP.append(0)
    if i in h:
      DP[i] = -1
    else:
      if DP[i-1]>=0:
        DP[i] += DP[i-1]
      if DP[i-2]>=0:
        DP[i] += DP[i-2]
      DP[i] = DP[i] % 1000000007
  print(int(DP[N]))
Buggy python submission (verdict: Runtime Error):
s = list(map(int, input().split()))
sort(s)
if s == [5, 7, 7]:
  print("YES")
else:
  print("NO")

Fixed submission:
s = list(map(int, input().split()))
s.sort()
if s == [5, 5, 7]:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P =list(map(int,input().split()))
cnt = 1
for i in range(1,N):
  if min(P[0:i+1]) < P[i]:
    cnt = cnt
  else:
    cnt += 1
print(cnt)
  

Fixed submission:
N = int(input())
P =list(map(int,input().split()))
cnt = 1
minPi = P[0]
for i in range(1,N):
  if minPi > P[i]:
    minPi = P[i]
  
  if minPi < P[i]:
    cnt = cnt
  else:
    cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
H=int(input())
A=int(input())
count=0
while H>0:
    H=H-A
    count+=1
else:
    print(count)

Fixed submission:
H,A=map(int, input().split())
count=0
while H>0:
    H=H-A
    count+=1
else:
    print(count)

Buggy python submission (verdict: Runtime Error):
H=int(input())
A=int(input())
count=0
while H>0:
    H=H-A
    count+=1
else:
print(count)

Fixed submission:
H,A=map(int, input().split())
count=0
while H>0:
    H=H-A
    count+=1
else:
    print(count)
Buggy python submission (verdict: Runtime Error):
S=input()
for i in range(len(S)):
    if S[i]==S[i+1]:
        print('Bad')
    else:
        print('Good')

Fixed submission:
S=input()
if S[0]!=S[1] and S[1]!=S[2] and S[2]!=S[3]:
    print('Good')
else:
    print('Bad')
Buggy python submission (verdict: Runtime Error):
n,x= [int(i) for i in input().split()]
L=[int(i) for i in input().split()]
d=[0]
for i in range(1,len(L)+1):
    dd=d[i-1]+L[i-1]
    d.append(dd)
for j in range(len(d)):
    if d[j]<=x:
        num+=1
print (num)

Fixed submission:
n,x= [int(i) for i in input().split()]
L=[int(i) for i in input().split()]
d=[0]
for i in range(1,len(L)+1):
    dd=d[i-1]+L[i-1]
    d.append(dd)
num=0
for j in range(len(d)):
    if d[j]<=x:
        num+=1
print (num)
Buggy python submission (verdict: Runtime Error):
n,k= [int(i) for i in input().split()]
if k==1:
    return 0
else:
    return n-k

Fixed submission:
n,k= [int(i) for i in input().split()]
if k==1:
    print (0)
else:
    print (n-k)

Buggy python submission (verdict: Runtime Error):
n=list(map(int,input().split(" ")))

if n[1]==1:
    return 0
else:
    return n[0]-n[1]

Fixed submission:
n,k= [int(i) for i in input().split()]
if k==1:
    print (0)
else:
    print (n-k)

Buggy python submission (verdict: Runtime Error):
n=int(input().split(" "))

if n[1]==1:
    return 0
else:
    return n[0]-n[1]

Fixed submission:
n,k= [int(i) for i in input().split()]
if k==1:
    print (0)
else:
    print (n-k)

Buggy python submission (verdict: Runtime Error):
n,k=input().split(" ")
n,k_int=map(int,n,k)
if k==1:
    return 0
else:
    return n-k

Fixed submission:
n,k= [int(i) for i in input().split()]
if k==1:
    print (0)
else:
    print (n-k)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split(" ")
if k==1:
    return 0
else:
    return n-k

Fixed submission:
n,k= [int(i) for i in input().split()]
if k==1:
    print (0)
else:
    print (n-k)

Buggy python submission (verdict: Runtime Error):
if k==1:
    return 0
else:
    return n-k

Fixed submission:
n,k= [int(i) for i in input().split()]
if k==1:
    print (0)
else:
    print (n-k)

Buggy python submission (verdict: Runtime Error):
n,k=input().split(" ")
if k==1:
    return 0
else:
    return n-k

Fixed submission:
n,k= [int(i) for i in input().split()]
if k==1:
    print (0)
else:
    print (n-k)

Buggy python submission (verdict: Runtime Error):
if k==1:
    return 0
elif n==k:
    return 0
else:
    max_dif=(n-k-1)-1
    return max_dif

Fixed submission:
n,k= [int(i) for i in input().split()]
if k==1:
    print (0)
else:
    print (n-k)
Buggy python submission (verdict: Runtime Error):
H = int(input())

cnt = 0
ans = 0

while H >= 1:
    H = H / 2
    if cnt == 0:
        cnt += 1
        ans += 1
    else:
        ans += cnt * 2
        cnt = cnt * 2

print(ans)


Fixed submission:
H, A = map(int, input().split())

cnt = 0

while H > 0:
    H = H - A
    cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
List = [int(x) for x in input().split()]


for i in range(K):
    if not List:
        print('0')
        exit()
    List.remove(max(List))

print(sum(List))


Fixed submission:
N, K = map(int, input().split())
List = [int(x) for x in input().split()]

if K == 0:
    print(sum(List))
    exit()

if N <= K:
    print('0')
    exit()

List.sort(reverse=True)
del List[:K]

print(sum(List))
Buggy python submission (verdict: Runtime Error):
from sys import stdin


N, M = map(int, stdin.readline().rstrip().split())
A_list = [stdin.readline().rstrip().split() for _ in range(M)]

wa_count, ac_count = 0, 0
WA_List = {}  # {prob_id: wa_count}
AC_list = []  # [prob_id]

for i in range(M):
    if A_list[i][1] == 'AC':
        if not A_list[i][0] in AC_list:
            if A_list[i][0] in WA_List:
                wa_count += WA_List[A_list[i][0]]
            ac_count += 1
            AC_list.append(A_list[i][0])
    else:
        if A_list[i][0] in WA_List:
            WA_List[A_list[i][0]] += 1
        else:
            WA_List[A_list[i][0]] = 1

print(ac_count, wa_count)


Fixed submission:
C = str(input())

print(chr(ord(C) + 1))

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
A_list = [input().split() for _ in range(M)]

wa_count, ac_count = 0, 0
WA_List = {}  # {prob_id: wa_count}
AC_list = []  # [prob_id]

for i in range(M):
    if A_list[i][1] == 'AC':
        if not A_list[i][0] in AC_list:
            if A_list[i][0] in WA_List:
                wa_count += WA_List[A_list[i][0]]
            ac_count += 1
            AC_list.append(A_list[i][0])
    else:
        if A_list[i][0] in WA_List:
            WA_List[A_list[i][0]] += 1
        else:
            WA_List[A_list[i][0]] = 1

print(ac_count, wa_count)


Fixed submission:
C = str(input())

print(chr(ord(C) + 1))
Buggy python submission (verdict: Runtime Error):
from sys import stdin
import math

# A = int(stdin.readline().rstrip())
A, B = [int(x) for x in stdin.readline().rstrip().split()]
# print(A, B)

if A < B:
    A, B = B, A

print((A * B) // math.gcd(A, B))


Fixed submission:
from sys import stdin
import fractions

A, B = [int(x) for x in stdin.readline().rstrip().split()]

print((A * B) // fractions.gcd(A, B))

Buggy python submission (verdict: Runtime Error):
from sys import stdin
import math

# A = int(stdin.readline().rstrip())
A, B = [int(x) for x in stdin.readline().rstrip().split()]
# print(A, B)

print((A * B) // math.gcd(A, B))


Fixed submission:
from sys import stdin
import fractions

A, B = [int(x) for x in stdin.readline().rstrip().split()]

print((A * B) // fractions.gcd(A, B))

Buggy python submission (verdict: Runtime Error):
from sys import stdin
import math

A, B = [int(x) for x in stdin.readline().rstrip().split()]


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


print(lcm(A, B))


Fixed submission:
from sys import stdin
import fractions

A, B = [int(x) for x in stdin.readline().rstrip().split()]

print((A * B) // fractions.gcd(A, B))

Buggy python submission (verdict: Runtime Error):
from sys import stdin
import math

# A = int(stdin.readline().rstrip())
A, B = [int(x) for x in stdin.readline().rstrip().split()]
# print(A, B)


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


print(lcm(A, B))


Fixed submission:
from sys import stdin
import fractions

A, B = [int(x) for x in stdin.readline().rstrip().split()]

print((A * B) // fractions.gcd(A, B))

Buggy python submission (verdict: Runtime Error):
from sys import stdin
import math

# A = int(stdin.readline().rstrip())
A, B = [int(x) for x in stdin.readline().rstrip().split()]
# print(A, B)


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


print(lcm(A, B))


Fixed submission:
from sys import stdin
import fractions

A, B = [int(x) for x in stdin.readline().rstrip().split()]

print((A * B) // fractions.gcd(A, B))
Buggy python submission (verdict: Runtime Error):
from sys import stdin
import fractions

N = stdin.readline().rstrip().split()
A = [int(x) for x in stdin.readline().rstrip().split()]
# print(N)
# print(A)
nex = 1
ans = 0

for i in range(N):
    if A[i] == nex:
        nex += 1
    else:
        ans += 1

print(-1) if N == ans else print(ans)


Fixed submission:
from sys import stdin
import fractions

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
# print(N)
# print(A)
nex = 1
ans = 0

for i in range(N):
    if A[i] == nex:
        nex += 1
    else:
        ans += 1

print(-1) if N == ans else print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# https://atcoder.jp/contests/abc051/tasks/abc051_b

# n n,
K, S = map(int, input().split())

# initialize
ans = 0

# logic: 全探索: 基本形
for i in range(K + 1):
    if i + K + 1 + K + 1 < S:
        continue
    for j in range(K + 1):
        if i + j + K + 1 < S:
            continue
        if 0 <= S - i - j <= K:
            ans += 1

print(ans)


Fixed submission:
k,s=map(int,input().split())
count=0
for a in range(k+1):
  for b in range(k+1):
    if 0<=s-a-b<=k:
      count+=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
# https://atcoder.jp/contests/abc051/tasks/abc051_b

# n n,
K, S = map(int, input().split())

# initialize
ans = 0

# logic: 全探索: 基本形
for i in range(K + 1):
    if i + K+1 + K+1 < S:
        continue
    for j in range(K + 1):
        if i + j + K+1 < S:
            continue
        for k in range(K + 1):
            if i+j+k == S:
                ans += 1

print(ans)


Fixed submission:
k,s=map(int,input().split())
count=0
for a in range(k+1):
  for b in range(k+1):
    if 0<=s-a-b<=k:
      count+=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
# https://atcoder.jp/contests/abc051/tasks/abc051_b

# n n,
K, S = input().split()

# initialize
ans = 0

# logic: 全探索: 基本形
for i in range(int(K) + 1):
    if i + int(K) + 1 + int(K) + 1 < int(S):
        continue
    for j in range(int(K) + 1):
        if j + int(K) + 1 + int(K) + 1 < int(S):
            continue
        for k in range(int(K) + 1):
            xyz = i + j + k
            if xyz == int(S):
                ans += 1

print(ans)


Fixed submission:
k,s=map(int,input().split())
count=0
for a in range(k+1):
  for b in range(k+1):
    if 0<=s-a-b<=k:
      count+=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
# https://atcoder.jp/contests/abc051/tasks/abc051_b

# n n,
K, S = input().split()

# initialize
ans = 0

# logic: 全探索: 基本形
for i in range(int(K)+1):
    for j in range(int(K)+1):
        for k in range(int(K)+1):
            xyz = i + j + k
            if xyz == int(S):
                ans += 1

print(ans)


Fixed submission:
k,s=map(int,input().split())
count=0
for a in range(k+1):
  for b in range(k+1):
    if 0<=s-a-b<=k:
      count+=1
print(count)