program ALIBABA;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var n,m,i,t,j,buf,s,a:integer;
c:array [1..1000] of integer;
begin

assignfile(input,'ALIBABA.IN');
reset(input);
readln(t);
for i:=1 to t do begin
s:=0;
 read(n);

 readln(m);

 for j := 1 to n do
 read(c[j]);
  for a := 1 to n-1 do begin
  for j := n-1 downto a  do begin
  if c[j]>c[j+1] then begin
   buf:=c[j];
   c[j]:=c[j+1];
   c[j+1]:=buf;
  end;
  end;
  end;
   for j :=1 to m do begin
    s:=c[n]+s;
    n:=n-1;
   end;
  writeln(s);

end;
  close(input);
end.
