let () = let n, k = Scanf.scanf "%d %d\n" @@ fun a b -> a, b in let arr = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun d -> d in let () = Array.fast_sort (fun x y -> y-x) arr in let (ans, _) = Array.fold_left (fun (ans, i) b -> if i < k && b > 0 then (ans+b, i+1) else (ans, i+1)) (0,0) arr in print_int ans