main = do
    getLine
    ls <- map read . words <$> getLine
    print $ analyze ls
    
analyze :: [Int] -> Int
analyze ls = if remain /= 0 then (length ls) - remain else -1
             where remain = countscore ls 1

countscore :: [Int] -> Int -> Int
-- リスト→今のインデックス
countscore [] num = num - 1
countscore ls num
    | head ls == num                = countscore (tail ls) (num+1)
    | otherwise                     = countscore (tail ls) num