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

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = "# cook your dish here\ndef bin(arr,l,r,val,n):\n ans=n\n while(l<=r):\n  mid=(l+r)//2\n  if(arr[mid]<=val):\n   l=mid+1\n  else:\n   ans=mid\n   r=mid-1\n return ans\n\n\nt=int(input())\nwhile(t):\n n=int(input())\n arr=list(map(int,input().strip().split(' ')))\n pre=[]\n suff=[0]*n\n pre.append(1)\n for i in range(1,n):\n  if(arr[i]>arr[i-1] and pre[i-1]==1):\n   pre.append(1)\n  else:\n   pre.append(0)\n flag=0\n temp=0\n for i in range(n-1,-1,-1):\n  if(i==n-1):\n   suff[i]=1\n  elif(arr[i]<arr[i+1] and suff[i+1]==1):\n   suff[i]=1\n  else:\n   if(flag==0):\n    temp=i+1\n    #print(temp)\n    suff[i]=0\n    flag=1\n   else:\n    suff[i]=0\n    #flah=1\n \n #print(pre,end=' ')\n #print()\n #print(suff,end='')\n #print(temp)\n count=0\n y=n\n for i in range(n):\n  y=n\n  if(pre[i]==1):\n   count+=1\n   if(temp>i+1):\n    y=bin(arr,temp,n-1,arr[i],n)\n   elif(i+2<n):\n    y=bin(arr,i+2,n-1,arr[i],n)\n   #print(y)\n   count+=(n-y)\n     #print(n-j)\n     #break\n count+=(n-temp)\n if(pre[temp]==1):\n  count-=2\n print(count)\n t-=1"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13887