Given an array $A_1, A_2, ..., A_N$, count the number of subarrays of array $A$ which are non-decreasing.

A subarray $A[i, j]$, where $1 ≤ i ≤ j ≤ N$ is a sequence of integers $A_i, A_i+1, ..., A_j$.
A subarray $A[i, j]$ is non-decreasing if $A_i ≤ A_i+1 ≤ A_i+2 ≤ ... ≤ A_j$. You have to count the total number of such subarrays.

-----Input-----
- 
The first line of input contains an integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- 
The first line of each test case contains a single integer $N$ denoting the size of array.
- 
The second line contains $N$ space-separated integers $A_1$, $A_2$, …, $A_N$ denoting the elements of the array.

-----Output-----
For each test case, output in a single line the required answer.

-----Constraints-----
- $1 ≤ T ≤ 5$
- $1 ≤ N ≤ 10^5$
- $1 ≤ A_i ≤ 10^9$

-----Subtasks-----
- Subtask 1 (20 points) : $1 ≤ N ≤ 100$
- Subtask 2 (30 points) : $1 ≤ N ≤ 1000$
- Subtask 3 (50 points) : Original constraints

-----Sample Input:-----
2
4
1 4 2 3
1
5

-----Sample Output:-----
6
1

-----Explanation-----
Example case 1.

All valid subarrays are $A[1, 1], A[1, 2], A[2, 2], A[3, 3], A[3, 4], A[4, 4]$.

Note that singleton subarrays are identically non-decreasing.
Example case 2.

Only single subarray $A[1, 1]$ is non-decreasing.

Difficulty: MEDIUM

Solutions:
def su(i):
	return i * (i + 1) // 2
i = int(input())
listk = []
for _ in range(i):
	kk = int(input())
	k = input().split()
	k2 = []
	for i in k:
		k2.append(int(i))
	imp = []
	st = 0
	for i in range(len(k2) - 1):
		if k2[i] > k2[i + 1]:
			imp.append(k2[st:i + 1])
			st = i + 1
		if i == len(k2) - 2:
			imp.append(k2[st:])
	tot = 0
	for ele in imp:
		tot = tot + su(len(ele))
	if len(k2) == 1:
		tot = 1
	listk.append(tot)
for ele in listk:
	print(ele)


def count_subarrays(arr):
	n = len(arr)
	dp = [0] * n
	dp[0] = 1
	for i in range(1, n):
		if arr[i] >= arr[i - 1]:
			dp[i] = dp[i - 1] + 1
		else:
			dp[i] = 1
	return sum(dp)
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	print(count_subarrays(arr))


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	c = [1] * n
	for i in range(n - 1):
		if l[i] <= l[i + 1]:
			c[i + 1] = c[i] + 1
	print(sum(c))


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.append(-1)
	s = 0
	(i, j, c) = (0, 1, 0)
	while j < len(a):
		if a[j] < a[j - 1]:
			s += (j - i) * (1 + j - i) / 2
			i = j
		j += 1
	print(int(s))


import sys

def iinput():
	return int(sys.stdin.readline().strip())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
for _ in range(iinput()):
	n = iinput()
	c = 0
	t = get_list()
	l = [1] * n
	for i in range(1, n):
		if t[i - 1] <= t[i]:
			l[i] += l[i - 1]
	print(sum(l))