open Batteries
open Printf
let () =
  let n = Scanf.scanf "%d " (fun a -> a) in
  let k = Scanf.scanf "%d " (fun a -> a) in
  let a_lst = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in

  let l = List.sort (fun x y -> compare y x) a_lst in
  let (ans_l,_) = List.split_nth k l in

  Printf.printf "%d\n" @@
  List.fold_left (+) 0 ans_l
