import Data.List

main = getLine >> getLine >>= print.solve.map read.words
solve as = min (f bs) (f cs) where
  bs = snd $ unzip $ scanl f (10^9, -1) as where
    f (mi,_) a = let m = min mi a in (m, a-m)
  cs = snd $ unzip $ scanr f (0, -1) as where
    f a (ma,_) = let m = max a ma in (m, m-a)
  f xs = length $ filter (==ma) xs where ma = maximum xs