{-# LANGUAGE FlexibleContexts #-}

import Control.Monad
import Data.List

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

get = map read . words <$> 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