import           Control.Monad
import           Data.Array
import qualified Data.ByteString.Char8 as BS
import           Data.List
import           Data.Maybe
import           Data.Ord

readInts :: IO [Int]
readInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

main = do
  n <- read <$> getLine
  nums <- readInts
  print $ solve n 0 nums

solve :: Int -> Int -> [Int] -> Int
solve n acc []
  | acc == 0 = -1
  | otherwise = n - acc
solve n acc (x:xs)
  | acc + 1 == x = solve n x xs
  | otherwise = solve n acc xs
