ZhenlongDai/ACPR huggingface dataset:
Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
L = list(map(int, input().split()))


number = 1
ans = -1
for x in L:
    if(x == number):
        number += 1
        ans = x

if(ans == -1):
    print(-1)
elif(ans ==1):
    print(1)
else:
    print(N - number +1)

Failing test case input:
3
-1 1 -3

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
L = list(map(int, input().split()))


number = 1
ans = 0
for x in L:
    if(x == number):
        number += 1
        ans += 1

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

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))

counter = 1

ans = 0

for a in A:
    if a == counter:
        counter += 1
    else:
        ans += 1

print(ans)


Failing test case input:
3
-1 4 -3

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))

counter = 1

ans = 0

for a in A:
    if a == counter:
        counter += 1
    else:
        ans += 1

if ans == len(A):
    print(-1)
else:
    print(ans)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))

check = 1
ans = 0

for i in range(n):
    if a[i] == check:
        check += 1
        ans += 1

print(n - ans)


Failing test case input:
3
5 0 0

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))

check = 1
ans = 0

for i in range(n):
    if a[i] == check:
        check += 1
        ans += 1

if ans == 0:
    print(-1)
else:
    print(n - ans)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = [int(i) for i in input().split()]
now = 1 
for i in range(N):
	if now == A[i]:
		now += 1 
print("{}".format(N - now + 1))

Failing test case input:
1
93

Expected output:
-1


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(i) for i in input().split()]
now = 1 
for i in range(N):
	if now == A[i]:
		now += 1 
if now == 1 :
  	print(-1)
else:
	print("{}".format(N - now + 1))

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
L = list(map(int, input().split()))


number = 1
ans = -1
for x in L:
    if(x == number):
        number += 1
        ans = x

if(ans == -1):
    print(-1)
elif(ans ==1):
    print(0)
else:
    print(N - number +1)

Failing test case input:
10
4 1 5 1 10 31 1 11 0 3

Expected output:
9


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
L = list(map(int, input().split()))


number = 1
ans = 0
for x in L:
    if(x == number):
        number += 1
        ans += 1

if(ans == 0):
    print(-1)
else:
    print(N - ans)
Problem: p02832
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
la = [int(w) for w in input().split()]

ans = 0
i = 1
for a in la:
    if a != i:
        ans += 1
    else:
        i += 1
print(ans)


Failing test case input:
3
2 -1 -2

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
la = [int(w) for w in input().split()]

ans = 0
i = 1
for a in la:
    if a != i:
        ans += 1
    else:
        i += 1
if ans == n and i == 1:
    ans = -1

print(ans)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    from collections import deque
    n, *a = map(int, open(0).read().split())
    a = deque(a)
    now = 0
    ind = 1
    m = n
    tmp = 0
    while a:
        now = a.popleft()

        if now == ind:
            ind += 1
            tmp = now
        else:
            m -= 1

    if tmp == m:
        print(n - m)
    else:
        print(-1)


if __name__ == '__main__':
    main()


Failing test case input:
3
5 0 -1

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
def main():
    from collections import deque
    n, *a = map(int, open(0).read().split())
    a = deque(a)

    tar = 1
    gab = 0
    while a:
        i = a.popleft()
        if i != tar:
            gab += 1
        else:
            tar += 1

    if gab == n:
        print(-1)
    else:
        print(gab)


if __name__ == '__main__':
    main()

Problem: p02832
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))
j = 1
n = 0
while n < N-1:
    try:
        n = A.index(j,n,N-1)
        n += 1 
        j += 1   
    except ValueError:
        j = j-1
        if j == 0:
            print(-1)
        else:
            print(N-j)
        exit()
if A[N-1] == j:
    print(N-j)
else:
    print(N-j-1)

Failing test case input:
10
4 1 5 1 11 31 2 11 0 3

Expected output:
7


Actual output:
8


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))
j = 1
n = 0
while n <= N-1:
    try:
        n = A.index(j,n)
        n += 1 
        j += 1   
    except ValueError:
        j = j-1
        if j == 0:
            print(-1)
        else:
            print(N-j)
        exit()
print(N-j+1)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
count = 1
ans = 0
point = 0
n = int(input())
t = list(map(int,input().split()))
for i,j in enumerate(t):
	if j == count:
		ans += i - point
		point = i + 1
		count += 1
if not point == n:
	ans += n - 1 - point
if count == 1:
	try:
		t.index(1)
	except:
		ans = -1
print(ans)


Failing test case input:
10
3 1 4 1 5 17 1 11 0 3

Expected output:
9


Actual output:
8


Fixed submission (verdict: Accepted):
count,ans,point = 1,0,0
n = int(input())
t = list(map(int,input().split()))
for i,j in enumerate(t):
	if j == count:
		ans += i - point
		point = i + 1
		count += 1
if not point == n:
	ans += n - point
if count == 1:
	try:
		t.index(1)
	except:
		ans = -1
print(ans)
Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
ans = []
cnt = 0
for i in range(1, n + 1):
    j = i
    cnt = 0
    try:
        while i != a[j - 1]:
            cnt += 1
            j += 1
    except IndexError:
        break

if 1 not in set(a):
    print(-1)
else:
    print(cnt)

Failing test case input:
10
3 1 4 1 5 17 2 6 4 3

Expected output:
7


Actual output:
4


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
cnt = 0
k = 0
for i in range(1, n + 1):
    try:
        while i != a[k]:
            cnt += 1
            k += 1
    except IndexError:
        break
    k += 1

if 1 not in set(a):
    print(-1)
else:
    print(cnt)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))

cnt = 0
num = 1
for i in range(n):
  if a[i] == num :
    num += 1
    continue
  cnt += 1

print(cnt if num > 1 else 0)


Failing test case input:
3
0 2 -3

Expected output:
-1


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))

cnt = 0
num = 1
for i in range(n):
  if a[i] == num :
    num += 1
    continue
  cnt += 1

print(cnt if num > 1 else -1)

Problem: p02832
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from sys import stdin 
n = int(stdin.readline().rstrip())
s = [int(x) for x in stdin.readline().rstrip().split()]
t = 1
answer = 0
for i in range(n):
    if s[i] == t:
        t += 1
    else:
        answer += 1
print(answer)



Failing test case input:
3
5 0 0

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
from sys import stdin 
n = int(stdin.readline().rstrip())
s = [int(x) for x in stdin.readline().rstrip().split()]
t = 1
answer = 0
for i in range(n):
    if s[i] == t:
        t += 1
    else:
        answer += 1
if answer == n:
    print(-1)
else:
    print(answer)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

N = int(input())
a = list(map(int, input().split()))
num = 1
while len(a) >= 1:
    if num in a:
        a = a[a.index(num) +1 :]
        num += 1
    else:
        print(-1)
        exit()
else:
    print(N - num + 1)

Failing test case input:
3
0 1 -7

Expected output:
2


Actual output:
-1


Fixed submission (verdict: Accepted):

N = int(input())
a = list(map(int, input().split()))
num = 0
for i in range(N):
    if a[i] == num + 1:
        num += 1
if num == 0:
    print(-1)
else:
    print(N - num)
Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
n=int(input())
a=list(map(int,input().split()))

purged_data = [] 
tmp = a[0] - 1
s=1
for i, e in enumerate(a):
    if e==s:
        purged_data.append(e)
        tmp = e
        s+=1
for i in range(len(purged_data)):
    if purged_data[i]!=i+1:
        print(-1)
        sys.exit()
if len(purged_data)==0:
    print(-1)
    sys.exit()
print(len(a)-len(purged_data),purged_data)

Failing test case input:
3
1 4 -2

Expected output:
2


Actual output:
2 [1]


Fixed submission (verdict: Accepted):
import sys
n=int(input())
a=list(map(int,input().split()))

purged_data = [] 
tmp = a[0] - 1
s=1
for i, e in enumerate(a):
    if e==s:
        purged_data.append(e)
        tmp = e
        s+=1
for i in range(len(purged_data)):
    if purged_data[i]!=i+1:
        print(-1)
        sys.exit()
if len(purged_data)==0:
    print(-1)
    sys.exit()
print(len(a)-len(purged_data))

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
N=int(input())
a = sys.stdin.readline().split()
i=1
for num in a:
    if int(num) == i:
        i=i+1
if i != 1:
    print(N-i+1)

Failing test case input:
3
2 4 -2

Expected output:
-1


Actual output:

Fixed submission (verdict: Accepted):
import sys
N=int(input())
a = sys.stdin.readline().split()
i=1
for num in a:
    if int(num) == i:
        i=i+1
if i != 1:
    print(N-i+1)
else:
    print(-1)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = list(map(int, input().split()))
break_list=[]
for i in range(len(a)):
    if a[i]<=i+1:
        x=i+1-a[i]
        break_list.append(x)
if len(break_list) != 0:
	print(min(break_list))
else:
  print(-1)

Failing test case input:
3
0 1 -4

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
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(c))

Problem: p02832
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N=int(input())
A=list(map(int,input().split()))
s=1
i=0
while i<N:
  if s==A[i]:
    s+=1
  i+=1
mi=N-s
if mi==N:
  print(-1)
else:
  print(mi)

Failing test case input:
10
3 1 5 1 19 31 2 3 0 3

Expected output:
7


Actual output:
6


Fixed submission (verdict: Accepted):
N=int(input())
A=list(map(int,input().split()))
s=1
i=0
while i<N:
  if s==A[i]:
    s+=1
  i+=1
mi=N-(s-1)
if 1 not in A:
  print(-1)
else:
  print(mi)
Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
number=input().split(' ')
number_list=[]
index=1
flag=0
for i in number_list:
    if(i==1):
        flag=1
    elif i==index:
        index+=1

if(flag==0):
    print(-1)
else:
    print(index)

Failing test case input:
10
3 1 5 1 11 31 2 11 0 3

Expected output:
7


Actual output:
-1


Fixed submission (verdict: Accepted):
N=int(input())
number=input().split(' ')
number_list=[]
for i in number:
    number_list.append(int(i))
index=1
flag=0
count=0
for i in number_list:
    if(i==1 and flag==0):
        flag=1
        index+=1
    elif (i==index):
        index+=1
    else:
        count+=1

if(flag==0):
    print(-1)
else:
    print(count)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = list(map(int,input().split()))
i = 0
j = 1
ANS = []
while i < N:
    x = a[i]
    if x == j:
        ANS.append(x)
        j += 1
    i += 1
ans = N - len(ANS)
if ans == 0:
    ans = -1
print(ans)

Failing test case input:
3
0 2 -3

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
a = list(map(int,input().split()))
i = 0
j = 1
while i < N:
    x = a[i]
    if x == j:
        j += 1
    i += 1
ans = N - j + 1
if ans == N:
    ans = -1
print(ans)

Problem: p02832
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())

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

nxt = 1
broken = 0
for i in range(n):
  if B[i]==nxt:
    nxt += 1
  else:
    broken += 1
    
print(broken)

Failing test case input:
3
5 0 0

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())

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

nxt = 1
broken = 0
for i in range(n):
  if B[i]==nxt:
    nxt += 1
  else:
    broken += 1
    
if broken==n:
  print(-1)
else:
  print(broken)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
_ = input()
l = list(map(int, input().split()))

print(l)

br = 0
cn = 1
for i, n in enumerate(l):
	
	if n != cn:
		br += 1
	else:
		cn += 1
if br == len(l):
	print(-1)
else:
	print(br)

Failing test case input:
3
2 6 -2

Expected output:
-1


Actual output:
[2, 6, -2]
-1


Fixed submission (verdict: Accepted):
_ = input()
l = list(map(int, input().split()))
br = 0
cn = 1
for i, n in enumerate(l):
	
	if n != cn:
		br += 1
	else:
		cn += 1
if br == len(l):
	print(-1)
else:
	print(br)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))
cnt = 1
for i in range(n):
    if a[i] == cnt:
        print('i',a[i])
        cnt += 1
cnt -= 1
if cnt > 0:
    print(n-cnt)
else:
    print(-1)

Failing test case input:
3
1 4 -2

Expected output:
2


Actual output:
i 1
2


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))
cnt = 1
for i in range(n):
    if a[i] == cnt:
        cnt += 1
        
cnt -= 1
if cnt > 0:
    print(n-cnt)
else:
    print(-1)
Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
brick_nums = input().split()

broken = 0
X = 0

for i in range(N):
    for j in range(X,N):
        if str(i+1) != "".join(brick_nums[j]):
            broken += 1
        else:
            X = j+1
            break
        
if broken >= N:
    print(-1)
else:
    print(broken)

Failing test case input:
10
3 1 5 1 19 42 2 3 0 3

Expected output:
7


Actual output:
-1


Fixed submission (verdict: Accepted):
N = int(input())
brick_nums = list(map(int , input().split()))

X = 1
broken = 0

if  1 not in brick_nums:
    print(-1)

else:
    for i in range(N):
        if X == brick_nums[i]:
            X += 1
        else:
            broken += 1
        
    print(broken)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
hoge=list(map(int,input().split()))
flag=1
punch=0
for i in range(n):
  if(hoge[i]==flag):
    flag+=1
  else:
    punch+=1
    
if(punch==n):
  print(-1)
else:
  print(n-punch)

Failing test case input:
3
-1 1 -3

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n=int(input())
hoge=list(map(int,input().split()))
flag=1
punch=0
for i in range(n):
  if(hoge[i]==flag):
    flag+=1
  else:
    punch+=1
    
if(punch==n):
  print(-1)
else:
  print(punch)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    n, *a = map(str, open(0).read().split())
    s = ''.join(a)

    m = 1
    cnt = 0
    while 1:
        ind = s.find(str(m))
        if ind == -1:
            cnt += len(s)
            break
        s = s[ind + 1:]
        cnt += ind
        m += 1

    if cnt == n:
        print(-1)
    else:
        print(cnt)


if __name__ == '__main__':
    main()


Failing test case input:
3
0 4 -7

Expected output:
-1


Actual output:
4


Fixed submission (verdict: Accepted):
def main():
    from collections import deque
    n, *a = map(int, open(0).read().split())
    a = deque(a)

    tar = 1
    gab = 0
    while a:
        i = a.popleft()
        if i != tar:
            gab += 1
        else:
            tar += 1

    if gab == n:
        print(-1)
    else:
        print(gab)


if __name__ == '__main__':
    main()

Problem: p02832
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
aas = list(map(int, input().split()))
if n == 1 and aas == [1]:
    print(0)
    exit()
t = 0
for i in aas:
    if i == t + 1:
        t += 1
print(n-t if t > 1 else -1)

Failing test case input:
3
1 -2 -1

Expected output:
2


Actual output:
-1


Fixed submission (verdict: Accepted):
n = int(input())
aas = list(map(int, input().split()))
if n == 1 and aas == [1]:
    print(0)
    exit()
t = 0
for i in aas:
    if i == t + 1:
        t += 1
print(n-t if t > 0 else -1)
Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = [int(x) for x in input().split()]

save = 1
ans = -1
tmp = []
for i in range(1,200000):
    tmp.append(i)

for i in a:
    if save == i:
        if i == 1:
            ans += 1
        save += 1
    else:
        ans += 1
if a == tmp[:len(a)]:
    print(0)
else:
    print(ans if len(a)-1 != ans else '-1')

Failing test case input:
3
0 1 -11

Expected output:
2


Actual output:
-1


Fixed submission (verdict: Accepted):
n = int(input())
a = [int(x) for x in input().split()]

save = 1
ans = -1
tmp = []
for i in range(1,200000):
    tmp.append(i)

flag = False

for i in a:
    if save == i:
        if i == 1:
            ans += 1
            flag = True
        save += 1
    else:
        ans += 1
if a == tmp[:len(a)]:
    print(0)
else:
    if flag:
        print(ans)
    else:
       print(-1)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


n = int(input())

a_list = list(map(int, input().split(' ')))
result = []

c = 0
for i in range(1, n+1):
    for j in range(c, n):
        if i == a_list[j]:
            result.append(i)
            c = i
            break
    if len(result) != i:
        break



if len(result) == 0:
    print(-1)
else:
    print(n - len(result))
        
    


Failing test case input:
10
3 1 4 1 5 17 2 6 4 3

Expected output:
7


Actual output:
4


Fixed submission (verdict: Accepted):


n = int(input())
a_list = list(map(int, input().split(' ')))
result = []

c = 0
for i in range(1, n+1):
    for j in range(c, n):
        if i == a_list[j]:
            result.append(i)
            c = j
            break
    if len(result) != i:
        break

if len(result) == 0:
    print(-1)
else:
    print(n - len(result))

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import sys
N = int(input())
A=[int(i) for i in input().split()]


i=2 
brick_remain =set()
if 1 not in A:
    print(-1)
else:
    brick_remain.add(1)
    for a in A:
        if a ==i:
            brick_remain.add(a)
            i +=1
            
    

brick_destroy = N - len(brick_remain)
if brick_remain==[]:
    print(-1)
else:
    print(brick_destroy)

Failing test case input:
3
0 2 -4

Expected output:
-1


Actual output:
-1
3


Fixed submission (verdict: Accepted):

import sys
N = int(input())
A=[int(i) for i in input().split()]



if 1 not in A:
    print(-1)
    exit
else:
    i=1 
    brick_remain =set() 
    for a in A:
        if a ==i:
            brick_remain.add(a)
            i +=1
    brick_destroy = N - len(brick_remain)       
    print(brick_destroy)
Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
number = list(map(int,input().split()))
count = 0
if not 1 in number:
    print(-1)
else:
    for i in range(N):
        now = i+1
        if now in number:
            
            count += number.index(now)
            number[:number.index(now)+1]=[]

        else:
            count += len(number)
    print(count)

Failing test case input:
3
0 1 -11

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
number = list(map(int,input().split()))
count = 0
if not 1 in number:
    print(-1)
else:
    nownumber = 1
    nowindex = 0
    for i in range(N):
        if number[i]  == nownumber:
            count += 1
            nownumber += 1
        else:
            pass
    print(N-count)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def getdata_input():
    while True:
        yield input()

it=getdata_input()
N=int(next(it))
arr=[-1]*N
arr[0],*arr[1:]=map(int,next(it).split())
n=1
out=[]
i=-1
while True:
    try:
        i=arr.index(n,i+1)
        out.append(i)
        n+=1
    except ValueError:
        if(i<N-1):
            out.append(N)
        break
if len(out) ==0: 
    print(-1)
else:
    i,j=0,0
    total=0
    for x in out:
        j=x
        total+=(j-i)
        i=j+1
        
    print(total)

Failing test case input:
3
2 -2 -1

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
def getdata_input():
    while True:
        yield input()

it=getdata_input()
N=int(next(it))
arr=[-1]*N
arr[0],*arr[1:]=map(int,next(it).split())
n=1
out=[]
i=-1
while True:
    try:
        i=arr.index(n,i+1)
        out.append(i)
        n+=1
    except ValueError:
        if i<N-1 and n>1 :
            out.append(N)
        break
if len(out) ==0: 
    print(-1)
else:
    i,j=0,0
    total=0
    for x in out:
        j=x
        total+=(j-i)
        i=j+1
        
    print(total)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = list(map(int,input().split()))
count = currentnum = 0

if a==(list(i+1 for i in range(N))):
       print(0)
       exit()

for i in a:
  if i!=currentnum+1: count+=1
  else: currentnum+=1
print(-1 if count==0 else count)

Failing test case input:
3
0 2 -3

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
a = list(map(int,input().split()))
count = currentnum = 0

if a==(list(i+1 for i in range(N))):
       print(0)
       exit()

for i in a:
  if i!=currentnum+1: count+=1
  else: currentnum+=1
print(-1 if currentnum==0 else count)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = [int(i) for i in input().split()]
sum = 0
for i in range(N):
    if sum + 1 == A[i]:
        sum = sum + 1
print(N-sum)


Failing test case input:
3
0 2 -6

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(i) for i in input().split()]
sum = 0
for i in range(N):
    if sum + 1 == A[i]:
        sum = sum + 1
if sum == 0:
    print(-1)
else:
    print(N-sum)
Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A = int(input())
B = list(map(int,input().split(" ")))
memory = 1
for i in range(A):
    if B[i] == memory:
        memory += 1
    else:
        continue
print(A-(memory-1))

Failing test case input:
3
-1 4 -3

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
A = int(input())
B = list(map(int,input().split(" ")))
memory = 1
for i in range(A):
    if B[i] == memory:
        memory += 1
    else:
        continue
if A-(memory-1) == A:
    print("-1")
else:
    print(A-(memory-1))

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    from collections import deque
    n, *a = map(int, open(0).read().split())
    a = deque(a)
    now = 0
    ind = 1
    m = n
    while a:
        now = a.popleft()

        if now == ind:
            ind += 1
        else:
            m -= 1

    if now == m:
        print(n - m)
    else:
        print(-1)


if __name__ == '__main__':
    main()


Failing test case input:
3
5 0 0

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
def main():
    from collections import deque
    n, *a = map(int, open(0).read().split())
    a = deque(a)

    tar = 1
    gab = 0
    while a:
        i = a.popleft()
        if i != tar:
            gab += 1
        else:
            tar += 1

    if gab == n:
        print(-1)
    else:
        print(gab)


if __name__ == '__main__':
    main()

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
ans = 0
cnt = 1
for x in a:
  if x == cnt:
    cnt += 1
  else:
    ans += 1
print(ans)

Failing test case input:
3
2 -1 -2

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
ans = 0
cnt = 1
for x in a:
  if x == cnt:
    cnt += 1
  else:
    ans += 1
if ans == n:
  print(-1)
else:
  print(ans)

Problem: p02832
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
a = [int(item) for item in input().split()]

ans = 0
cur = 1
last = 0

if 1 not in a:
    print(-1)
else:
    for i in range(n):
        if a[i] == cur:
            ans += last
            last = 0
            cur += 1
        else:
            last += 1

    print(ans)


Failing test case input:
3
1 -2 -2

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
a = [int(item) for item in input().split()]

ans = 0
cur = 1
last = 0

if 1 not in a:
    print(-1)
else:
    for i in range(n):
        if a[i] == cur:
            ans += last
            last = 0
            cur += 1
        else:
            last += 1

    print(ans + last)
Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

from sys import stdin
N = int(stdin.readline().rstrip())
a = [int(x) for x in stdin.readline().rstrip().split()]

cnt = 0
idx = 1
flg = 1
for i in a:
	if i == idx:
		idx = idx + 1
		flg = 0
	else:
		cnt = cnt + 1
		flg = 1

if flg == 1:
	print(-1)
else:
	print(cnt)



Failing test case input:
10
3 1 9 1 20 2 2 3 -1 6

Expected output:
7


Actual output:
-1


Fixed submission (verdict: Accepted):

from sys import stdin
N = int(stdin.readline().rstrip())
a = [int(x) for x in stdin.readline().rstrip().split()]

cnt = 0
idx = 1

for i in a:
	if i == idx:
		idx = idx + 1
		
	else:
		cnt = cnt + 1
		
			

if cnt == N:
	print(-1)
else:
	print(cnt)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
a = list(map(int,input().split()))

j=1
ans=0
tmp=0
for i in range(0,N):
  if a[i]==j:
    ans += i-tmp
    tmp = i+1
    j += 1
print(i,j,ans,tmp)

if ans==0 and tmp==N:
  print(ans)
elif ans==0 and j==1:
  print(-1)
elif N>tmp:
  print(ans+(N-tmp))
else:
  print(ans)

Failing test case input:
10
4 1 5 1 10 31 1 11 0 3

Expected output:
9


Actual output:
9 2 1 2
9


Fixed submission (verdict: Accepted):
N=int(input())
a = list(map(int,input().split()))

j=1
ans=0
tmp=0
for i in range(0,N):
  if a[i]==j:
    ans += i-tmp
    tmp = i+1
    j += 1


if ans==0 and tmp==N:
  print(ans)
elif ans==0 and j==1:
  print(-1)
elif N>tmp:
  print(ans+(N-tmp))
else:
  print(ans)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))

i = 1
ind = 0
if 1 in a:
    while i in a[ind:]:
    	ind = a.index(i)
    	i += 1
    print(n-i+1)
else:
    print(-1)


Failing test case input:
10
3 1 4 1 5 17 2 6 1 3

Expected output:
7


Actual output:
4


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))
k = 1

for i in a:
    if k == i:
        k += 1

if k == 1:
    print(-1)
else:
    print(n-k+1)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
a=list(map(int,input().split()))

i=0
index=0

if 1 in a:
    while len(a)>0 and index<N-1:
        if i+1 in a[index:]:
            
            index=a[index:].index(i+1)
            i+=1
            
        else:
            break
    
    print(N-i)
else:
    print(-1)

Failing test case input:
10
3 1 4 1 5 9 2 6 4 3

Expected output:
7


Actual output:
4


Fixed submission (verdict: Accepted):
N=int(input())
a=list(map(int,input().split()))

base=1
count=0

if 1 in a:
    for i in range(N):
        if a[i]==base:
            count+=1
            base+=1
        else:
            pass

    
    print((N-count)%N)
else:
    print(-1)
Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def inp():
 return [int(x) for x in input().split()]

N = int(input())
a = inp()

n = 1
i = 0 

k = 0

while i<N:
  while i<N and a[i]!=n:
    i+=1
    k+=1
  i+=1
  n+=1
print(k)



Failing test case input:
1
93

Expected output:
-1


Actual output:
1


Fixed submission (verdict: Accepted):
def inp():
 return [int(x) for x in input().split()]

N = int(input())
a = inp()

n = 1
i = 0 

k = 0

while i<N:
  while i<N and a[i]!=n:
    i+=1
    k+=1
  i+=1
  n+=1

if N==k:
  print(-1)
else:
  print(k)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a = list(map(int,input().split()))
b=1
ans=0
for i in a:
  if i==b:
    b+=1
  else:
    ans+=1
print(ans)

Failing test case input:
3
2 6 -2

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
n=int(input())
a = list(map(int,input().split()))
b=1
ans=0

if 1 not in a:
    print(-1)
    exit()

for i in a:
  if i==b:
    b+=1
  else:
    ans+=1
print(ans)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = list(map(int,input().split()))
count = currentnum = 0

for i in a:
  if i!=currentnum+1: count+=1
  else: currentnum+=1
print(-1 if count==0 else count)

Failing test case input:
3
0 4 -7

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
a = list(map(int,input().split()))
count = currentnum = 0

if a==(list(i+1 for i in range(N))):
       print(0)
       exit()

for i in a:
  if i!=currentnum+1: count+=1
  else: currentnum+=1
print(-1 if currentnum==0 else count)

Problem: p02832
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N=int(input())
a=list(map(int,input().split()))
num=1
ans=0
for i in range(N):
    if a[i]==num:
        num+=1
    else:
        ans+=1
print(ans)


Failing test case input:
3
5 0 0

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
N=int(input())
a=list(map(int,input().split()))
num=1
ans=0
for i in range(N):
    if a[i]==num:
        num+=1
    else:
        ans+=1
print(ans if ans!=N else -1)
Problem: p02832
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
total_breaks = 0
position = 0
for i in range(1, n + 1):
    try:
        next_position = a.index(i)
        if next_position < position:
            total_breaks = total_breaks + n - position
            break
        total_breaks = total_breaks + next_position - position
        position = next_position + 1
    except ValueError:
        if position == 0:
            total_breaks = -1
            break
        else:
            total_breaks = total_breaks + n - position
            break
print(total_breaks)

Failing test case input:
10
3 1 4 1 5 9 2 6 4 3

Expected output:
7


Actual output:
8


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
total_breaks = 0
position = 0
for i in range(1, n + 1):
    try:
        next_position = a.index(i, position)
        if next_position < position:
            total_breaks = total_breaks + n - position
            break
        total_breaks = total_breaks + next_position - position
        position = next_position + 1
    except ValueError:
        if position == 0:
            total_breaks = -1
            break
        else:
            total_breaks = total_breaks + n - position
            break
print(total_breaks)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))




idx = 0
bf_idx = 0
num = 1
brick = 0
flg = False
while True:
    if num == A[idx]:
        flg = True
        num += 1
        brick += idx - bf_idx
        bf_idx = idx + 1
    idx += 1
    if idx > N - 1:
        break

if flg == False:
    brick = -1
print(brick)

Failing test case input:
10
3 1 10 1 20 2 2 3 0 3

Expected output:
7


Actual output:
5


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))




idx = 0
cnt = 0
num = 1
brick = 0
flg = False
while True:
    if num == A[idx]:
        flg = True
        num += 1
        brick += cnt
        cnt = 0
    else:
        cnt += 1
    idx += 1
    if idx > N - 1:
        brick += cnt
        break

if flg == False:
    brick = -1

print(brick)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))
ni = 1
ret = 0
for i in a:
  if i == ni:
    ni += 1
  else:
    ret += 1
print(ret)

Failing test case input:
3
-1 4 -3

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))
ni = 1
ret = 0
for i in a:
  if i == ni:
    ni += 1
  else:
    ret += 1
print(ret if ret != n else -1)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
m=1
for i in range(n):
  if a[i]==m:
    m+=1
if m==1:
  print(-1)
print(n-m+1)

Failing test case input:
3
0 2 -4

Expected output:
-1


Actual output:
-1
3


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
m=1
for i in range(n):
  if a[i]==m:
    m+=1
if m==1:
  print(-1)
else:
  print(n-m+1)
Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))

x = 1
aa = 0
for i in a:
    if i != x:
        print(i,x)
        aa += 1
    else:
        x += 1
print(aa)

Failing test case input:
3
2 -1 -2

Expected output:
-1


Actual output:
2 1
-1 1
-2 1
3


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))

x = 1
b = 0
for i in a:
    if i != x:
        b += 1
    elif i == x:
        x += 1

if b == n:
    print(-1)
else:
    print(b)

Problem: p02832
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
cur = 1
ok = False
for i in a:
  if cur == i:
    ok = True
    cur += 1
if not ok:
  print(-1)
else:
  print(n-cur)

Failing test case input:
10
4 1 4 1 10 31 1 11 0 3

Expected output:
9


Actual output:
8


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
cur = 1
ok = False
for i in a:
  if cur == i:
    ok = True
    cur += 1
if ok == False:
  print(-1)
else:
  print(n-cur+1)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
A = list(map(int, input().split()))
count = 0
tmp=0
for i in range(N):
    if A[i]!=tmp+1:
        count +=1
    else:
        tmp+=1
print(count)


Failing test case input:
3
2 -1 -2

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
N=int(input())
A = list(map(int, input().split()))
count = 0
tmp=0
for i in range(N):
    if A[i]!=tmp+1:
        count +=1
    else:
        tmp+=1
if count==N:
    print(-1)
else:
    print(count)

Problem: p02832
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N = int(input())
Ali = list(map(int,input().split()))
s = 1
res = 0

for i in range(N):
  if Ali[i] == s:
    s += 1
  else:
    res += 1
    
print(res)

Failing test case input:
1
93

Expected output:
-1


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
Ali = list(map(int,input().split()))
s = 1
res = 0

for i in range(N):
  if Ali[i] == s:
    s += 1
  else:
    res += 1
    
if s == 1:
  print(-1)
else:
  print(res)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))

if not 1 in a:
    print(-1)

count = 1
smash = 0
for i in a:
    if i == count:
        count += 1

    else:
        smash += 1

print(smash)

Failing test case input:
3
2 -2 -2

Expected output:
-1


Actual output:
-1
3


Fixed submission (verdict: Accepted):
import sys
n = int(input())
a = list(map(int, input().split()))

if not 1 in a:
    print(-1)
    sys.exit()

count = 1
smash = 0
for i in a:
    if i == count:
        count += 1

    else:
        smash += 1

print(smash)
Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
count=1
sum1=0
for i in range(n):
    if a[i]==count:
        count+=1
    else:
        sum1+=1
if n==sum:
    print("-1")
else:
    print(sum1)

Failing test case input:
1
93

Expected output:
-1


Actual output:
1


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
count=1
sum1=0
for i in range(n):
    if a[i]==count:
        count+=1
    else:
        sum1+=1
if n==sum1:
    print("-1")
else:
    print(sum1)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))

ans = 0

for e in a:
  if e == (ans+1):
    ans += 1
    
print(n-ans)


Failing test case input:
3
2 -2 -2

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))

ans = 0

for e in a:
  if e == (ans+1):
    ans += 1
    
if ans == 0:
  print(-1)
else:
  print(n - ans)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def getdata_input():
    while True:
        yield input()
        
it=getdata_input()
N=int(next(it))
arr=[-1]*N
arr[0],*arr[1:]=map(int,next(it).split())
n=1
out=[]
i=N
arr2=arr[::-1]
while True:
    try:
        x=arr2.index(n,0,i)
        out.append(i-x-1)
        i=x
        n+=1
    except ValueError:
        break
if len(out) ==0: 
    print(-1)
else:        
    print(sum(out))

Failing test case input:
10
3 1 10 1 20 2 2 3 -1 6

Expected output:
7


Actual output:
5


Fixed submission (verdict: Accepted):
def getdata_input():
    while True:
        yield input()

it=getdata_input()
N=int(next(it))
arr=[-1]*N
arr[0],*arr[1:]=map(int,next(it).split())
n=1
out=[]
i=-1
while True:
    try:
        i=arr.index(n,i+1)
        out.append(i)
        n+=1
    except ValueError:
        if i<N-1 and n>1 :
            out.append(N)
        break
if len(out) ==0: 
    print(-1)
else:
    i,j=0,0
    total=0
    for x in out:
        j=x
        total+=(j-i)
        i=j+1
        
    print(total)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
A=list(map(int,input().split()))
c=1
for a in A:
    if a==c:
        c+=1
print(n-c+1)

Failing test case input:
1
-5

Expected output:
-1


Actual output:
1


Fixed submission (verdict: Accepted):
n=int(input())
A=list(map(int,input().split()))
c=1
for a in A:
    if a==c:
        c+=1
if c==1:
   print(-1)
else:
    print(n-c+1)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = list(map(int, input().split()))

i = 1
j = 0

if not 1 in set(a):
    print(-1)

while i in set(a[j:]) and j < N:
    j = a[j:].index(i) + j
    
    i += 1

print(N - i + 1)


Failing test case input:
1
-5

Expected output:
-1


Actual output:
-1
1


Fixed submission (verdict: Accepted):
N = int(input())
a = list(map(int, input().split()))

i = 1


if 1 in set(a):
    
    
    
    
    for a_i in a:
        if a_i == i:
            i += 1
    print(N - i + 1)
else:
    print(-1)
Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input());
s = list(map(int,input().split()))
ans = 0
for i in range(n):
  if (s == sorted(s,reverse=True)) or (s == sorted(s,reverse=False)):
    break
  else:
    ans +=1
    s.pop(0)
print(ans)

Failing test case input:
3
-1 4 -3

Expected output:
-1


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input());
s = list(map(int,input().split()))
if 1 not in s:
    print(-1)
    exit()
c = 1
ans = 0
for i in range(n):
  if s[i] != c:
    ans += 1
  else:
    c += 1
print(ans)

Problem: p02832
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))

idx = 1
ans = 0
length = len(A)
lis = []
for a in A:
  if a == idx:
    lis.append(idx)
    idx += 1
    continue
  else:
    ans += 1
    length -= 1

if lis == list(range(1, length+1)):
  print(ans)
else:
  print(-1)
    

Failing test case input:
3
-1 4 -3

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))

idx = 1
ans = 0
length = len(A)
lis = []
for a in A:
  if a == idx:
    lis.append(idx)
    idx += 1
    continue
  else:
    ans += 1
    length -= 1

if lis != [] and lis == list(range(1, length+1)):
  print(ans)
else:
  print(-1)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    n = int(input())
    a = [int(x) for x in input().split()]

    idx = 1
    cnt = 0
    for i in range(n):
        if idx == a[i]:
            idx += 1
        else:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()

Failing test case input:
3
5 0 -1

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
def main():
    n = int(input())
    a = [int(x) for x in input().split()]

    idx = 1
    cnt = 0
    for i in range(n):
        if idx == a[i]:
            idx += 1
        else:
            cnt += 1
    if cnt==n:
        print(-1)
    else:
        print(cnt)


if __name__ == '__main__':
    main()

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():

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

    ans = 0
    p = 1
    for i in range(N):
        if a[i] != p:
            ans += 1
        else:
            p += 1
    return ans


if __name__ == '__main__':
    print(main())

Failing test case input:
3
2 6 -2

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
def main():

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

    if 1 not in a: return -1
    ans = 0
    p = 1
    for i in range(N):
        if a[i] != p:
            ans += 1
        else:
            p += 1
    return ans


if __name__ == '__main__':
    print(main())
Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A=[]  
A=[int(x) for x in input().split()]
num = 1
count = 0
for i in range(N):
  if A[i] == num:
    num += 1
  else:
    count += 1
if count >= N-1:
  print(-1)
else:
  print(count)
  

Failing test case input:
3
0 1 -3

Expected output:
2


Actual output:
-1


Fixed submission (verdict: Accepted):
N = int(input())
A=[]  
A=[int(x) for x in input().split()]
num = 1
count = 0

for i in range(N):
  if A[i] == num:
    num += 1
  else:
    count += 1
if count == N:
  print(-1)
else:
  print(count)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
tmp=1
block=[]
for i in range(n):
    if a[i]==tmp:
        block.append(a[i])
        tmp+=1
print(n-len(block))

Failing test case input:
3
5 0 0

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
tmp=1
block=[]
for i in range(n):
    if a[i]==tmp:
        block.append(a[i])
        tmp+=1
if len(block)>0:
    print(n-len(block))
else:
    print(-1)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))

s = 1
count = 0
fail = 0
ans = 0
for a in A:
    if a == s:
        s += 1
        ans += count
        count = 0
    else:
        count += 1
        fail += 1

if s == 1:
    print(-1)
else:
    print(ans)

Failing test case input:
10
3 1 9 1 20 2 2 3 -1 6

Expected output:
7


Actual output:
5


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))

s = 1
break_count = 0
ans = 0
for a in A:
    if a == s:
        s += 1
        ans += break_count
        break_count = 0
    else:
        break_count += 1

ans += break_count

if s == 1:
    print(-1)
else:
    print(ans)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a_list = list(map(int, input().split()))
dp = [0]*N 

if 1 not in a_list:
    print(-1)
else:
    dp[0]= 1
    count = 0
    for i in range(N-1):
        if dp[i] == a_list[i]:
            dp[i + 1] += 1
        else:
            dp[i + 1] = dp[i]
            count += 1
    print(count)

Failing test case input:
3
-1 1 -3

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
a_list = list(map(int, input().split()))
dp = [0]*N

if 1 not in a_list:
    print(-1)
else:
    dp[0]= 1
    count = 0
    for i in range(N-1):
        if dp[i] == a_list[i]:
            dp[i + 1] = dp[i] + 1
        else:
            dp[i + 1] = dp[i]
            count += 1

    if dp[N-1] != a_list[N-1]:
        count += 1
        
    print(count)
Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
ans=-1
temp=1
for i in range(n):
  if a[i]==temp:
    temp=temp+1
  elif ans==-1:
    ans=ans+2
  else:
    ans=ans+1
print(ans)

Failing test case input:
3
2 -1 -2

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
ans=0
temp=1
for i in range(n):
  if a[i]==temp:
    temp=temp+1
  else:
    ans=ans+1
if ans==n:
  print(-1)
else:
  print(ans)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
al = list(map(int,input().split()))
target = 1
ans = 0
for a in al:
    if a == target:
        target += 1
    else:
        ans += 1
if ans == 0:
    print(-1)
else:
    print(ans)

Failing test case input:
3
2 -1 -2

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
al = list(map(int,input().split()))
target = 1
ans = 0
for a in al:
    if a == target:
        target += 1
    else:
        ans += 1
if ans == N:
    print(-1)
else:
    print(ans)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = list(map(int, input().split()))
x = 1
ans = 0
crash = 0

for i in range(N):
    if (a[i] == x):
        ans += crash
        crash = 0
        x += 1
        continue
    crash += 1


if (ans == 0 and crash != 0):
    print(-1)
else:
    print(ans + crash)

Failing test case input:
3
1 -2 -2

Expected output:
2


Actual output:
-1


Fixed submission (verdict: Accepted):
N = int(input())
a = list(map(int, input().split()))
x = 1
ans = 0

for i in range(N):
    if (a[i] == x):
        x += 1
        continue
    ans += 1


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

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
l=list(map(int,input().split()))
t=1
ans=0
for i in l:
    if i==t:
        t+=1
    else:
        ans+=1
if t==n:
    ans=-1
print(ans)

Failing test case input:
3
2 -2 0

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
n=int(input())
l=list(map(int,input().split()))
t=1
ans=0
for i in l:
    if i==t:
        t+=1
    else:
        ans+=1
if t==1:
    ans=-1
print(ans)

Problem: p02832
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
A = [int(i) for i in input().split(" ")]

now = 1
ans = 0
for i in A:
    if i == now:
        now += 1
    else:
        ans += 1
print(ans)

Failing test case input:
3
0 2 -3

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
A = [int(i) for i in input().split(" ")]

num = 1
ans = 0
for i in range(n):
    if A[i] == num:
        num += 1
        ans += 1
if ans == 0:
    print("-1")
else:
    print(n - ans)