module kkk
  sub main()
    
    dim N as long
    dim a
    
    dim i as long
    
    dim cnt as long
    
    N = console.readline()
    a = console.readline()
    a = split(a, " ")
    
    i = -1
    do while i < N - 1
      i = i + 1
      if a(i) = cnt + 1 then
        cnt = cnt + 1
      end if
    loop
    
    if cnt = 0 then
      console.writeline(-1)
    else 
      console.writeline(N - cnt)
    end if
    
  end sub
end module