program ALIBABA;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var s,n,m,t,i1,j,k,i:longint;
c: array [1..1000] of longint;
begin
assign (input, 'ALIBABA.in');
reset (input);
read (t);
for i1:=1 to t do
  begin
  read (n,m);
  for i:=1 to n do
    read (c[i]);
    s:=0;j:=0;

  for i:=1 to n-1 do

    for j:=i+1 to n do
    begin
    if (c[i]<c[j]) then
      begin
      k:=c[i];
      c[i]:=c[j];
      c[j]:=k;
      end;end;


    for i:= 1 to m do
    s:=s +c[i];
     writeln (s);
     end;




end.
