let () =
  Scanf.scanf "%d %d\n" @@ fun n k ->
  let l = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun d -> d in
  let _ = Array.fast_sort (fun x y -> y-x) l in
  let ans = ref 0 in
  for i = 0 to k-1 do
    ans := !ans + l.(i)
  done;
  Printf.printf "%d\n" !ans