main = do
    n <- read <$> getLine
    a <- map read <$> words <$> getLine
    let ret = solve 1 a
    print $ if ret == 0 then -1 else n - ret

solve :: Int -> [Int] -> Int
solve n []                  = n - 1
solve n (h : t) | h == n    = solve (succ n) t
                | otherwise = solve n t
