object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = Integer.parseInt(sc.next)
  val list = List.fill(n)(Integer.parseInt(sc.next))
  
  val num = list.scan(1)((a, _) => list(a - 1)).indexOf(2)
  
  println(num)
}