program main
	implicit none
	integer(8):: N,i,j,t,B,K
	integer,dimension(1:2*10**6)::A    	
	read *, N
    read(*,*) (A(i), i = 1, N)
    j=1;t=0
	do i=1,N
		if(A(i)==j)then
		j=1+j
		t=1
		end if
	end do
	
	if(j>1.and.t==1)print'(I0)',N-j+1
	if(j>0.and.t==0)print'(I0)',-1
	if(j==1.and.t==1)print'(I0)',0
	
end program main