import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (n : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  as <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  let
    k = f 0 . map (subtract 1) $ as
  print $ if k == 0 then (-1) else (n - k)

f :: Int -> [Int] -> Int
f i (x : xs) | x == i = f (succ i) xs
             | otherwise = f i xs
f i _ = i

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n
