 var  a:array [1..200000] of byte;
   i, n, q, sum, rez, l, r, gl , igl: longint;

begin
  readln (gl);
  for igl := 1 to gl do begin
  rez :=0;

  read (n,q);
  for i:=1 to n do
   read (a[i]);
  readln();
  for l:=1 to n do
    begin
      sum :=0;
      for r:=l to n do
       begin
         sum := sum + a[r];
         if (sum * 2 >= r - l + 1)
           then inc (rez);
       end;
    end;
  write (rez);
  if (gl <> igl) then write (' ');
    end;
end.

