let n, t = Scanf.scanf "%d %d\n" (fun x y -> x, y)

let rec read_ints accu = function
  | 0 -> List.rev accu
  | k -> read_ints ((Scanf.scanf " %d" (fun x -> x)) :: accu) (k-1)

let a = Array.of_list (read_ints [] n)
let b = Array.make n 0

let () =
  b.(n-1) <- a.(n-1);
  for i = n-2 downto 0 do
    b.(i) <- max a.(i) b.(i+1)
  done;;

let c = ref 0 in
  let max = ref (-1) in
  for i = 0 to n-1 do
    if !max < b.(i)-a.(i) then begin max := b.(i)-a.(i); c := 1 end
    else if !max = b.(i)-a.(i) then c := !c + 1
  done;
  print_int !c
