import Control.Monad

main = do
  n <- readLn
  a <- map read <$> replicateM n getLine
  putStrLn . show $ solve n 1 n a

solve:: Int -> Int -> Int -> [Int] -> Int
solve n k 0 a = -1
solve n k nn a
  | kk == 2 = n - nn + 1
  | otherwise = solve n kk (nn - 1) a
  where
    kk = (a !! (k - 1))
