import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

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

main = do
    getLine
    as <- getIntList
    print $ (length as) - solve as

solve as | fas == 0 = length as + 1
         | otherwise = fas
    where fas = (foldl f 1 as) - 1

f a b | a == b = a + 1
      | otherwise = a