Scanf.scanf "%d %d" (fun n t ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in

    let rec loop i mi best count =
        if i = n then count else
            if a.(i) < mi        then loop (i + 1) a.(i) best count else
            if a.(i) - mi > best then loop (i + 1) mi (a.(i) - mi) 1           else
            if a.(i) - mi = best then loop (i + 1) mi  best        (count + 1) else
                                          loop (i + 1) mi  best count
    in
    loop 1 a.(0) 0 0 |> Printf.printf "%d\n"
)