import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    getLine
    as <- getIntList
    let zs = zipWith (\r l -> (r-l,r)) rs (tail ls)
            where ls = scanl min 1000000001 as
                  rs = scanr max 0 as
    let m = maximum $ map fst zs
    let ans = length . group $ filter ((== m).fst) zs
    print ans