program main
  integer(8) :: n, i, num
  integer(8), allocatable :: a(:)
  read(*,*) n
  allocate(a(n))
  read(*,*) a

  num = 1
  do i = 1, n
    if(a(i)==num) then
      num = num + 1
    end if
  end do
  num = num - 1
  if (num == 0) then
    write(6,*) -1
  else
    write(6,*) n-num
  end if
end program main