let rec tabulate n f = 
  let rec loop acc m =
    if m < n then loop (f m :: acc) (m + 1)
    else List.rev acc in
  loop [] 0

let () =
  let n, _ = Scanf.scanf "%d %d\n" (fun n t -> n, t) in
  tabulate n (fun _ -> Scanf.scanf "%d " (fun a -> a))
    |> List.fold_left (fun (acc, min, pred) a ->
        if a < pred then ((min, pred) :: acc, a, a)
        else (acc, min, a)) ([], max_int, max_int)
    |> (fun (acc, min, pred) -> (min, pred) :: acc)
    |> List.map (fun (min, max) -> max - min)
    |> (fun ranges ->
        let max = List.fold_left max 0 ranges in
        List.filter (( = ) max) ranges
          |> List.length)
    |> Printf.printf "%d\n"
