import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val n = sc.nextInt
  val as = Array.fill(n)(sc.nextInt)
  val result = execute(as, 1, 0)
  println(if (result < n) result else -1)

  def execute(array: Array[Int], next: Int, deleted: Int): Int = array match {
    case _ if array.isEmpty => deleted
    case _ if array.head == next => execute(array.tail, next + 1, deleted)
    case _ => execute(array.tail, next, deleted + 1)
  }
}
