var
a:array[1..1000] of integer;
x,q,t,max,j,k,i,n,m:integer;
begin
assign(input,'alibaba.in'); reset(input);
readln(t);
for i:=1 to t do begin
readln(n,m);
for j:=1 to n do read(a[j]);
readln;
for j:=1 to n do
for q:=1 to n-1 do
if a[q]<a[q+1] then begin
x:=a[q]; a[q]:=a[q+1]; a[q+1]:=x;
end;
max:=0;
for j:=1 to m do
max:=max+a[j];
writeln(max);
end;
end.