solve :: [Int] -> Int -> Int
solve _ 0 = 0
solve hs level = count hs 0 level + solve hs (level - 1)

count :: [Int] -> Int -> Int -> Int
count [] _ _ = 0
count (h:hs) curr target = point + count hs next target
  where next = if h >= target then target else 0
        point = if next > curr then 1 else 0

main :: IO ()
main = do
  getLine
  hs <- map read . words <$> getLine
  print . solve hs $ maximum hs