module Main
  ( main
  )
where

import           Control.Applicative
import           Control.Monad
import           Data.List
import           Data.Array
import           Data.Char
import           Data.Bits
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

parseInt = fst . fromJust . BS.readInt
readInt = parseInt <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine

main = do
  n <- readInt
  arr <- readIntList
  let ans = foldl (\acc val -> if val == acc + 1 then acc + 1 else acc) 0 arr
  print $ if ans == 0 then -1 else n - ans
