program brick_break
    implicit none
    integer(4):: n, i, ni
    integer(4), allocatable:: a(:)

    read*, n
    allocate(a(n))
    read*, a(:)

    ni = 0
    i = 1
    do i=1,n
        if (a(i) == ni+1) ni = ni + 1
    end do

    if (ni == 0) then
        print*, -1
    else
        print*, n-ni
    endif
end program brick_break