var a,b,t,i,j,k,c,d,e,l:longint;
	m: array[1..1000] of longint;
begin
assign(input, 'alibaba.in');
reset(input);
readln(t);
for l:=1 to t do begin;
a:=0;
b:=0;
readln (a,b);
for i:=1 to a do read(m[i]);
 
for i:=1 to (a-1) do 
  begin
  
for j:=i to a do
  
if m[i]<m[j] then 
    begin
    k:=m[i];
    m[i]:=m[j];
    m[j]:=k;
    end;
  end;
 for i:=1 to a do begin;
d:=d+m[i]; if b=i then writeln(d);
end;
k:=0;d:=0;
readln;
end;
dec(t);
end.
