module M = Map.Make(struct type t = int let compare = (-) end)
let find_default k m v = try M.find k m with Not_found -> v

let () =
  Scanf.scanf "%d %d" @@ fun n t ->
  let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun x -> x)) in
  let d = Array.fold_left (fun (d, l) e -> (max d (e-l), min e l)) (0, a.(0)) a |> fst in
  a |> Array.fold_left (fun (z, m) v ->
    let p = find_default (v-d) m 0 in
    let c = find_default v m 0 in
    (z+p, M.add v (c+1) m)) (0, M.empty)
  |> fst |> Printf.printf "%d\n"