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 ma best count =
        if i = n then count else
            if a.(i) < mi then loop (i + 1) a.(i) ma best count else
                if a.(i) - mi = best then loop (i + 1) mi ma best (count + 1) else
                    if a.(i) > ma then loop (i + 1) mi a.(i) (a.(i) - mi) 1 else
                        loop (i + 1) mi ma best count
    in
    loop 0 1_000_000_000 0 (-1) 0 |> Printf.printf "%d\n"
)