program Project1;
{$APPTYPE CONSOLE}
{$MODE OBJFPC}
type
TArray = array of Cardinal;
function IsAscending(const A: TArray; AFrom, ATo: Integer): Boolean;
var
i: Integer;
begin
for i := AFrom + 1 to ATo do
if A[i - 1] > A[i] then
Exit(False);
Result := True;
end;
function ReadArray(out A: TArray): Boolean;
var
ArrLength, i: Integer;
begin
Readln(ArrLength);
if ArrLength <= 0 then
Exit(False);
SetLength(A, ArrLength);
for i := Low(A) to High(A) do
Read(A[i]);
Readln; // Skip end of line
Result := True;
end;
procedure DoTest;
var
i, j: Integer;
Arr: TArray;
CountOfAscendings: Integer;
begin
if not ReadArray(Arr) then
begin
Writeln('Bad array length');
Exit;
end;
CountOfAscendings := 0;
for i := Low(Arr) to High(Arr) do
begin
for j := i to High(Arr) do
if IsAscending(Arr, i, j) then
Inc(CountOfAscendings);
end;
Writeln(CountOfAscendings);
end;
var
TestsCount: Cardinal;
begin
Readln(TestsCount);
while TestsCount > 0 do
begin
DoTest;
Dec(TestsCount);
end;
Readln;
end.