(* O(n log n) *)
Scanf.scanf "%d %d" @@ fun n k ->
  let ls = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ (+) 0 in
  Array.sort (fun x y -> compare y x) ls;
  Array.sub ls 0 k |> Array.fold_left (+) 0 |> Printf.printf "%d\n"