Scanf.scanf "%d %d %d %d" (fun n m v p ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    Array.sort (fun a b -> compare b a) a;

    let judge x =
        if a.(x) + m < a.(p - 1) then false else
            let s = n - 1 - x + 1 + p - 1 in
            if s >= v then true else
                let rec loop k sum =
                    if k = x then sum else loop (k + 1) (sum + a.(x) + m - a.(k))
                in
                loop p (m * s) >= m * v
    in

    let rec bin left right =
        if left = right then left else
            let mid = left + (right - left) / 2 in
            if judge mid then bin (mid + 1) right
                         else bin left mid
    in
    let k = bin p n in
    Printf.printf "%d\n" @@ if judge k then k + 1 else k
)