let solve a_lst =
    let rec solve' lst min_a max_profit num_max =
        match lst with
        | [] -> num_max
        | x::xs ->
            let next_profit = x - min_a
            let next_mp, next_nm =
                if next_profit > max_profit then
                    (next_profit, 1)
                elif next_profit = max_profit then
                    (next_profit, num_max + 1)
                else (max_profit, num_max)
            let next_ma = min min_a x
            solve' xs next_ma next_mp next_nm
    
    let min_a = List.head a_lst
    let rest = List.tail a_lst
    solve' rest min_a 0 0

let () =
    let _ = stdin.ReadLine ()
    let a_lst = stdin.ReadLine () |>
                (fun str -> str.Split()) |>
                Array.map int |> List.ofArray
    solve a_lst |> printfn "%d"
