import Control.Applicative
import Control.Monad
 

main :: IO ()
main = do 
    n <- readLn
    nss <- map read . words <$> getLine
    putStrLn $ show (solve n nss)

solve :: Int -> [Int] -> Int
solve n nss = length (filter (==True) (map and  (zipWith (\x y -> map (x <=) y) nss lst)))
       where lst = [take a nss | a <- [1..n]]
