object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  val list = List.fill(n)(sc.nextInt)
  
  def check(list: Seq[Int], count: Int): Int = {
    val index = list.indexOf(count)
    if (index == -1) count - 1
    else check(list.drop(index + 1), count + 1)
  }
  
  val leftNum = check(list, 1)
  
  println(if (leftNum == 0) -1 else n - leftNum)
}