      PROGRAM brickBreak
      IMPLICIT NONE
      integer(16) :: n
      integer(16),allocatable :: a(:)
      integer(16) :: i,j,skip
      
      read*,n
      allocate( a(n) )
      read*,a
      
      
      
      j = 1
      skip = 0
      do i = 1,n
        if( a(i)==j )then
          j = j + 1
        else
          skip = skip + 1
        end if
      end do
      
      if( j==1 .and. skip==n )then
        print*,'-1'
      else
        print*,skip
      end if
      
      
      
      END PROGRAM