import Control.Monad(forM_)
import qualified Data.Vector as V

main = do
  ns <- fmap (fmap (read :: String -> Int) . words) . lines <$> getContents
  let n = head $ head ns
  let ls = V.fromList $ tail $ concat $ ns
  putStrLn $ show $ solve n ls

solve :: Int -> V.Vector Int -> Int
solve n ls = f n 1
  where
    f 0 _ = -1
    f m i
      | i == 2 = n - m
      | otherwise = f (subtract 1 m) $ ls V.! (subtract 1 i)     
