
{$APPTYPE CONSOLE}

var tests, predm_in, predm_out, z, i, j, k, x,  temp, allcost: integer; a: array[0..1000] of integer;
begin
     assign(input, 'ALIBABA.IN'); reset(input);
     readln(tests);

     for i := 1 to tests do
     begin
        allcost:=0;
        readln(predm_in, predm_out);
   

        for x := 1 to predm_in do
        begin
          read(temp);
          a[x]:=temp;
        end;

        for k := 0 to predm_in - 1 do
        for z := 0 to predm_in - k do
        begin
          if a[z] < a[z+1] then
              begin
                  temp:=a[z];
                  a[z]:=a[z+1];
                  a[z+1]:=temp;
              end;

        end;


        for j := 0 to predm_out-1 do
        begin
            allcost:=allcost+a[j];
        end;



        for k := 0 to predm_in-1  do
          a[k]:=0;
        writeln(allcost);
     end;
     
end.
