You are given a sequence $A_1, A_2, \ldots, A_N$. Calculate the number of ways to remove a non-empty contiguous subsequence from it such that the resulting sequence is non-empty and strictly increasing.
-----Input-----
- The first line of the input contains a single 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$.
- The second line contains $N$ space-separated integers $A_1, A_2, \ldots, A_N$.
-----Output-----
For each test case, print a single line containing one integer ― the number of ways.
-----Constraints-----
- $1 \le T \le 10$
- $1 \le N \le 10^5$
- $|A_i| \le 10^9$ for each valid $i$
-----Subtasks-----
Subtask #1 (40 points): $N \le 1,000$
Subtask #2 (60 points): original constraints
-----Example Input-----
2
3
1 1 2
4
2 4 3 5
-----Example Output-----
4
7
# cook your dish here
t=int(input())
while(t):
 n=int(input())
 arr=list(map(int,input().strip().split(' ')))
 pre=[]
 suff=[0]*n
 pre.append(1)
 for i in range(1,n):
  if(arr[i]>arr[i-1] and pre[i-1]==1):
   pre.append(1)
  else:
   pre.append(0)
 flag=0
 temp=0
 for i in range(n-1,-1,-1):
  if(i==n-1):
   suff[i]=1
  elif(arr[i]<arr[i+1] and suff[i+1]==1):
   suff[i]=1
  else:
   if(flag==0):
    temp=i+1
    #print(temp)
    suff[i]=0
    flag=1
   else:
    suff[i]=0
    #flah=1
 
 #print(pre,end=' ')
 #print()
 #print(suff,end='')
 #print(temp)
 count=0
 for i in range(n):
  if(pre[i]==1):
   count+=1
   for j in range(temp,n):
    if(arr[j]>arr[i] and j>i+1):
     count+=(n-j)
     #print(n-j)
     break
 count+=(n-temp)
 if(pre[temp]==1):
  count-=2
 print(count)
 t-=1
# cook your dish here
t=int(input())
while(t):
 n=int(input())
 arr=list(map(int,input().strip().split(' ')))
 pre=[]
 suff=[0]*n
 pre.append(1)
 for i in range(1,n):
  if(arr[i]>arr[i-1] and pre[i-1]==1):
   pre.append(1)
  else:
   pre.append(0)
 flag=0
 temp=0
 for i in range(n-1,-1,-1):
  if(i==n-1):
   suff[i]=1
  elif(arr[i]<arr[i+1] and suff[i+1]==1):
   suff[i]=1
  else:
   if(flag==0):
    temp=i+1
    #print(temp)
    suff[i]=0
    flag=1
   else:
    suff[i]=0
    #flah=1
 
 #print(pre,end=' ')
 #print()
 #print(suff,end='')
 #print(temp)
 count=0
 for i in range(n):
  if(pre[i]==1):
   count+=1
   for j in range(temp,n):
    if(arr[j]>arr[i] and j>i+1):
     count+=(n-j)
     #print(n-j)
     break
 count+=(n-temp)
 if(pre[temp]==1):
  count-=2
 print(count)
 t-=1