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 = 'for t in range(int(input())):\n n = int(input())\n a = list(map(int, input().split()))\n first_index = 0\n last_index = 0\n curr_index = 0\n indexes = [[0, 0]]\n for i in range(1,n):\n  if a[i] > a[i-1]:\n   last_index = i\n  else:\n   indexes[curr_index][1] = last_index\n   curr_index += 1\n   last_index += 1\n   first_index = last_index\n   indexes.append([first_index, last_index])\n indexes[curr_index][1] = last_index\n res = 0\n if len(indexes)>1:\n  res = indexes[0][1] - indexes[0][0] + 1\n  res += indexes[-1][1] - indexes[-1][0] + 1\n  first_range_last_index = indexes[0][1]\n  last_range_first_index = indexes[-1][0]\n  n -= 1\n  while first_range_last_index >= 0 and n>=last_range_first_index:\n   if a[n] <= a[first_range_last_index]:\n    res += len(a) - (n+1)\n    first_range_last_index -= 1\n   else:\n    n -= 1\n  if first_range_last_index>=0 :\n   res += (first_range_last_index+1) * (len(a) - (n+1))\n else:\n  res = (((n)*(n+1)) // 2)-1\n\n print(res)'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13647