import java.util.Scanner

import scala.annotation.tailrec

object Main extends App {
  val sc = new Scanner(System.in)
  val t = System.currentTimeMillis

  val n  = sc.nextInt
  val av = Seq.fill(n)(sc.nextInt)
  
  @tailrec
  def loop( vec: Seq[Int], target: Int = 1 ): Int = {
    val rest = vec.dropWhile(_ != target)
    (target, rest.isEmpty) match {
      case (1, true) => -1
      case (_, true) => target
      case _ => loop(rest.tail, target + 1 )
    }
  }

  val target = loop(av)
  val res = if(target == -1) -1 else n - target + 1

  println(res)

}

