program ABC148D
    integer N
    integer,allocatable,dimension(:)::A
    integer::num
    read*,N
    allocate(A(N))
    read*,A
    num=1
    do i=1,N
        if(A(i)==num)then
            num=num+1
        endif
    end do
    print"(i0)",merge(N-num+1,-1,num/=1)
    contains
end program