main = do
  n <- readLn
  p <- map read . words <$> getLine
  print $ func [n] p
  
func :: [Int] -> [Int] -> Int
func min [] = length min - 1
func min@(m:_) (x:xs) 
  | m >= x = func (x:min) xs
  | otherwise = func min xs