module kkk
  sub main()
 
    Dim N As Integer = Integer.Parse(Console.ReadLine)
    Dim a() As Integer = Array.ConvertAll(Of String, Integer)(Console.ReadLine.Split(" "), AddressOf Integer.Parse)

    
    dim i as long
    
    dim cnt as long
    
    for i = 0 to N - 1
      if a(i) = cnt + 1 then
        cnt = cnt + 1
      end if
  next
    
    if cnt = 0 then
      console.writeline(-1)
    else 
      console.writeline(N - cnt)
    end if
    
  end sub
end module