object Main extends App {
  @scala.annotation.tailrec
  def loop(ints: Seq[Int], i: Int): Int = ints match {
    case Seq() => i
    case x :: xs if x == i => loop(xs, i + 1)
    case _ :: xs => loop(xs, i)
  }
  val sc = new java.util.Scanner(System.in)
  val N = sc.nextInt()
  val count = loop(List.fill(N)(sc.nextInt()), 1) - 1
  println(if (count == 0) -1 else N - count)
}
