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 = 'def bin_search1(arr, x):\n s = 0\n e = len(arr)-1\n while s <= e:\n  m = (s+e)//2\n  if arr[m] > x:\n   e = m-1\n  else:\n   s = m+1\n  # print(s, e)\n # print(s)\n return s\n\n\ndef bin_search2(arr, x):\n s = 0\n e = len(arr)-1\n while s <= e:\n  m = (s+e)//2\n  if arr[m] >= x:\n   e = m-1\n  else:\n   s = m+1\n  # print(s, e)\n # print(s)\n return s\n\n\n\n\n\nt = int(input())\nfor i in range(t):\n n = int(input())\n arr = [int(j) for j in input().split()]\n var = 0\n flag = 0\n for i in range(n-1):\n  if arr[i+1] <= arr[i]:\n   var = 1\n   ind1 = i\n   break\n\n if var == 0:\n  print((n*(n+1))//2 -1)\n  continue\n\n\n for i in range(n-1, 0, -1):\n  if arr[i-1] >= arr[i]:\n   ind2 = i\n   break\n\n # print(ind1, ind2)\n arr1 = arr[:ind1+1]\n arr2 = arr[ind2:]\n\n # print(arr1, arr2)\n\n count = len(arr1) + len(arr2)\n for i in range(len(arr1)):\n  x = bin_search1(arr2, arr1[i])\n  # print(x)\n  count += len(arr2)+1-x\n\n # print(count)\n for i in range(len(arr2)):\n  x = bin_search1(arr1, arr2[i])\n  # print(x)\n  count += x+1\n\n print(count//2)\n\n\n\n\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13815