let () = Scanf.scanf "%d %d %d %d\n" @@ fun n m v p ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  Array.sort (fun a a' -> compare a' a) as_;
  let acc = Array.make (n + 1) 0 in
  for i = 0 to n - 1 do
    acc.(i + 1) <- as_.(i) + acc.(i)
  done;
  Printf.printf "%d\n" @@
  Array.fold_left ( + ) 0 @@
  Array.init n @@ fun i ->
    if
      as_.(p - 1) <= as_.(i) ||
      as_.(p - 1) <= as_.(i) + m &&
      acc.(i) - acc.(p - 1)
        <= min (i - p + 1) (n - v) * m + as_.(i) * (i - p + 1)
    then 1
    else 0

