import Control.Monad
import Data.List
import qualified Data.Vector.Storable as V

main=do
    n<-readLn
    as<-V.fromList <$> replicateM n readLn
    print $ chk 0 0 as

chk c b v = case n of
    0 -> (-1)
    1 -> c+1
    n -> chk (c+1) n v
    where n = (v V.! b) - 1