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


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


def inputInt():
    return int(input())


def main():
    N = inputInt()
    a = inputIntList()
    ans = 0
    index = 0
    while index < len(a):
        if not index in a:
            break
        if a[index] - 1 != index:
            a.remove(a[index])
            ans += 1
        else:
            index += 1
    return ans if ans != N else -1


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


Failing test case input:
3
2 -2 -2

Expected output:
-1


Actual output:
0


Fixed submission (verdict: Accepted):
import math


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


def inputInt():
    return int(input())


def main():
    N = inputInt()
    a = inputIntList()
    ans = 0
    look = 1
    for i in a:
        if look == i:
            look += 1
        else:
            ans += 1

    return ans if ans != N else -1


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

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

cnt = 0
track = 1

for i in range(n) :
	if cnt!=1 :
		if arr[i]!=track :
			arr[i] = -1
		else :
			track+=1
			cnt = 1
	else :
		if arr[i] !=track and arr[i]!=track-1 :
			arr[i] = -1
		else:
			track+=1


res = set(arr)

if -1 in res :
	res.remove(-1)

ans = n - len(res)

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


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())
arr = list(map(int,input().split()))

cnt = 0
track = 1

for i in range(n) :
	if cnt!=1 :
		if arr[i]!=track :
			arr[i] = -1
		else :
			track+=1
			cnt = 1
	else :
		if arr[i] == track :
			track+=1
		elif arr[i] == track - 1 :
			continue
		else:
			arr[i] = -1



res = set(arr)



if -1 in res :
	res.remove(-1)

ans = n - len(res)

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

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

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

Failing test case input:
3
5 0 -1

Expected output:
-1


Actual output:
3


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

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

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

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

counter = 1
for i in range(N):
    if a[i]==counter:
        counter +=1

print(N-counter+1)


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()))

counter = 1
for i in range(N):
    if a[i]==counter:
        counter +=1
if (N-counter+1)==N:
    print('-1')
else:
    print(N-counter+1)