import           Data.Maybe
import qualified Data.Vector     as V
import qualified Data.ByteString.Lazy.Char8    as BC

main = do
    n  <- readLn
    as <-
        V.fromList
        .   map (pred . fst . fromJust . BC.readInt)
        .   BC.lines
        <$> BC.getContents
    print $ fromMaybe (-1) $ V.elemIndex 1 $ V.iterateN (n+1) (as V.!) 0