open Batteries

let rec print_int_list = function
  | [] -> print_endline "DONE"
  | x :: xs -> Printf.printf "%d " x ; print_int_list xs

let () =
  let n, k = Scanf.scanf " %d %d " (fun n k -> (n, k)) in
  List.init n (fun _ -> Scanf.scanf " %d" (fun li -> li))
  |> List.sort (fun x y -> y - x)
  (* |> print_int_list *)
  |> List.take k |> List.fold_left ( + ) 0 |> Printf.printf "%d\n"
