Scanf.scanf "%d %d" (fun n k ->
    let l = Array.init n (fun _ -> Scanf.scanf " %d" (fun l -> l)) in
    Array.sort (fun a b -> compare b a) l;
    let rec loop i acc =
        if i = k then acc else loop (i + 1) (acc + l.(i))
    in
    Printf.printf "%d\n" @@ loop 0 0
)