import Control.Applicative
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.List
import Data.Char (isSpace)

main :: IO ()
main = solve <$> readLn <*> f >>= print
  where
    f = readil B.readInt <$> B.getLine

solve :: Int -> [Int] -> Int
solve n = g . fst . foldl' f (0, 1)
  where
    f (ct, i) x
      | i == x = (ct, i + 1)
      | otherwise = (ct + 1, i)
    g x
      | x == n = -1
      | otherwise = x

readil :: Integral a =>  (ByteString -> Maybe (a, ByteString)) -> ByteString -> [a]
readil f = unfoldr $ \s -> do
  (n, s') <- f s
  return (n, B.dropWhile isSpace s')
