main = do
  z <- readLn
  xs <- map read . words <$> getLine
  print $ solve z (1, 0) xs

solve z (_, m) [] = if z == m then -1 else m
solve z (n, m) (x:xs) =
  if n == x then
    solve z (n+1, m) xs
  else
    solve z (n, m+1) xs