import std.stdio, std.string, std.conv, std.algorithm, std.range;

void main() {
    auto input = readln.split.to!(int[]);
    auto N = input[0], K = input[1];
    auto l = readln.split.to!(int[]).sort();
    writeln(l[$-K..$].sum);
}
