
{$APPTYPE CONSOLE}
type DinamArray = array[0..0] of integer;
var tests, predm_in, predm_out, z, i, j, k, x,  temp, allcost: integer; a:^DinamArray;
begin
     assign(input, 'ALIBABA.IN'); reset(input);
     readln(tests);
     allcost:=0;
     for i := 1 to tests do
     begin
        readln(predm_in, predm_out);
        getmem(a, predm_in*sizeof(integer));

        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;
        writeln(allcost);
        freemem(a, predm_in*sizeof(integer));

        for k := 0 to predm_in-1  do
          a^[k]:=0;
        allcost:=0;
     end;

end.
