main :: IO ()
main = do
  l1 <- getLine
  l2 <- getLine
  let n = read l1 :: Int
      a = map read $ words l2 :: [Int]
      ans = length $ f 1 a
  print $ if ans == 0 then -1 else n - ans

f _ [] = []
f i l@(x:xs)
  | x == i = x:f (i + 1) xs
  | otherwise = f i xs