main :: IO ()
main = do
  n <- readLn
  an <- map (read :: String -> Int) . words <$> getLine
  print $ ans n 1 an

ans :: Int -> Int -> [Int] -> Int
ans n k [] = if k == 1 then -1 else n-k+1
ans n k (a:an) = if a == k then ans n (k+1) an else ans n k an