open Printf
open Scanf

let id x = x

let n, k = scanf "%d %d" (fun n k -> n, k)

let vs = Array.init n (fun i -> scanf " %d" id)

let () =
    Array.sort (fun x y -> y - x) vs;
    let r = ref 0 in
    for i = 0 to k - 1 do
        r := !r + vs.(i)
    done;
    printf "%d\n" !r

    