import Control.Monad
import qualified Data.ByteString.Char8 as C
import Data.List
import Data.Maybe

main = sol <$> (C.getLine *> get) >>= print

get = fmap fst . mapMaybe C.readInt . C.words <$> C.getLine

sol (a:as) = length . (elemIndices =<< maximum) $ f (a,a) as

f _ []        = []
f (l,r) (a:as)
  | a < l     = f (a,a) as
  | a > r     = (a-l):f (l,a) as
  | otherwise = f (l,r) as