local read = io.read
local N, K = read("*n", "*n")
local l = {}
for i = 1, N do
	l[i] = read("*n")
end

table.sort(l, function(x, y) return x > y end)
local out = 0
for i = 1, K do
	out = out + l[i]
end

print(out)
