import qualified Data.ByteString.Char8 as B
import           Data.List             (foldl', unfoldr)


main :: IO ()
main = do
  n <- readLn
  as <- readIntsLn
  print $ solve n as

solve :: Int -> [Int] -> Int
solve n as
  | k == 0    = -1
  | otherwise = n - k
  where k = foldl' f 1 as - 1

f :: Int -> Int -> Int
f x a
  | x == a    = x + 1
  | otherwise = x

readIntsLn :: IO [Int]
readIntsLn = unfoldr (B.readInt . B.dropWhile (== ' ')) <$> B.getLine
