program main
      implicit none
      integer :: n, k, cnt, i
      integer, allocatable :: a(:)

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

      k = 1
      cnt = 0
      do i = 1, n
        if ( a(i) == k ) then
          k = k + 1
        else
          cnt = cnt + 1
        end if
      end do

      if ( k == 1 ) then
        print *, '-1'
      else 
        print *, cnt
      end if

end program main

