import qualified Data.ByteString.Char8 as B

readInt :: B.ByteString -> Int
readInt = maybe undefined fst . B.readInt

readInts :: B.ByteString -> [Int]
readInts = map readInt . B.words

main = do
  getLine
  as <- readInts <$> B.getLine
  print (invisible 0 0 maxBound as)

invisible acc _ _ [] = acc
invisible acc dmax amin (a:as)
  | a < amin = invisible acc dmax a as
  | a - amin > dmax = invisible 1 (a - amin) amin as
  | a - amin == dmax = invisible (acc + 1) dmax amin as
  | otherwise = invisible acc dmax amin as