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 = "T = int(input())\n\ndef bSearch(A,suff, k, i, j):\n # print('-?', k, i, j)\n if i>=len(A):\n  return\n if i == j:\n  if suff[i]==False or A[j]<=A[k]:\n   return\n  return i\n mid = (i + j)//2\n if mid <= k:\n  return bSearch(A,suff, k, mid+1, j)\n else:\n  if A[mid] <= A[k] or suff[mid]==False:\n   return bSearch(A,suff, k, mid+1, j)\n  else:\n   return bSearch(A,suff, k, i, mid)\n\n\nfor _ in range(T):\n N = int(input())\n A = list(map(int, input().split()))\n pref = [False for _ in range(N)]\n suff = [False for _ in range(N)]\n pref[0] = True\n suff[-1] = True\n for i in range(1, N):\n  if A[i] > A[i-1]:\n   pref[i] = True\n  else:\n   break\n for i in reversed(range(N-1)):\n  if A[i] < A[i+1]:\n   suff[i] = True\n  else:\n   break\n\n count = 0\n for i in range(N):\n  if pref[i] == True:\n\n   j = bSearch(A,suff, i, i+1, N-1)\n   if j == None:\n    # print(i, N)\n    if i<N-1:\n     count += 1\n    # break\n   elif j == i+1:\n    count += N-j\n    # print(i, j, N-j)\n   else:\n    count += N - j + 1\n    # print(i, j, N-j+1)\n   \n for i in range(1, N):\n  if suff[i] == True:\n   count += 1\n \n print(count) "
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13541