main = do
  li <- getLine
  let n = read li
  li <- getLine
  let as = map read $ words li
  let ans = compute n as
  print ans

compute :: Int -> [Int] -> Int
compute n as = let m = loop 0 1 as in if n > m then m else -1

loop :: Int -- 砕く数カウント
     -> Int -- 次に現れてほしい数
     -> [Int] -- レンガ
     -> Int
loop c _ [] = c
loop c x (a:as)
  | x == a = loop c (succ x) as
  | True   = loop (succ c) x as
