
object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val a = Array.fill(n)(sc.nextInt())
  val max = a.max
  println(calc(a, 0, 1, 0))
  
  def calc(list :Array[Int], i: Int, t: Int, acc: Int): Int = {
    
    if (i >= list.length) {
      if (acc == list.length) {
        -1
      } else {
        acc
      }
    } else if (list(i) == t) {
      calc(list, i+1, t+1, acc)
    } else {
      calc(list, i+1, t, acc+1)
    }
  }
}