-- Question B

import Control.Applicative
import Control.Monad

main = do
  n <- readLn
  xs <- replicateM n readLn :: IO [Int]
  putStrLn $ show ( check xs 1 0 n )
  

check xs k i j 
   | i == j = -1
   | x == 2 = (i+1)
   | otherwise = check xs x (i+1) j
    where x = xs !! (k-1)