Chandler has again been invited to perform at a wedding ceremony. Last time, Chandler performed very well. However, he found out that people were a little bit raged due to varying quality of jokes. People don't want the decrease in quality of jokes.
He has n jokes in his mind and he also knows the quality of each joke. So, this time Chandler has decided to select a non-decreasing contiguous subarray of his jokes for the ceremony.
Non-Decreasing contiguous subarray means quality of jokes should not decrease in that contiguous subarray.
Help Chandler count the number of such contiguous subarrays.
What is Contiguous Subarray? :
Contiguous Subarray of an array means all continuous subsets of that array (continuous elements of an array).
Refer: link
For e.g. : Consider an array {2, 1, 2} then different possible contiguous subarrays are:- {2}, {1}, {2}, {2, 1}, {1, 2}, {2, 1, 2}. We can't consider {2, 2} as a subarray because it is not contiguous (as the elements are not continuous in original array).
See the sample case for better understanding.
Input format:
First line contains an integer T, denoting the number of test-cases.
Each testcase consists of 2 lines as shown below:-
First line contains an integer n.
Second line contains n integers (q1, q2, ...qn). Here, qi denotes quality of ith joke.
Output format:
For each testcase, print the number of non-decreasing subarrays that Chandler can select.
Constraints:
1 <= t <= 6
1 <= n <= 1000000
1 <= qi <= 1000000000 (10^9)
In first testcase, the possible subarrays are:-
{3} - Non-decreasing
{1} - Non-decreasing
{2} - Non-decreasing
{3, 1} - Decreasing
{1, 2} - Non-decreasing
{3, 1, 2} - Decreasing
Hence, the number of non-decreasing subarrays are 4.
In second testcase, the possible subarrays are:-
{4} - Non-decreasing
{3} - Non-decreasing
{4, 3} - Decreasing
Hence, the number of non-decreasing subarrays are 2.