program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var ij, ii,n,m,i,j,k:integer;
x:int64;
a:array[1..1000]of longint;

begin
 assign(input,'ALIBABA.IN'); reset(input);
 readln(ii);
 for ij := 1 to ii do
   begin
   readln(n,m);
   for i := 1 to n  do
   read(a[i]);

   for I := 1 to n do
     for j := 1 to n-1 do
     if a[j]>a[j+1] then begin k:=a[j]; a[j]:= a[j+1]; a[j+1]:=k; end;
     x:=0;

     for k := n downto n-m+1  do
       if a[k]>0 then inc(x,a[k]);
       writeln(x);
   end;
end.
