| Codeforces Round 1137 (Div. 2) |
|---|
| Contest is running |
| 00:42:40 |
| Score | |
|---|---|
| Problem A | 346 |
| Problem B | 519 |
| Problem C | 865 |
| Problem D | 1384 |
| Problem E | 1384 |
| Problem F | 1730 |
| Successful hack | 100 |
| Unsuccessful hack | -50 |
| Unsuccessful submission | -50 |
| Resubmission | -50 |
You are given a permutation$$$^{\text{∗}}$$$ of integers $$$p_1, p_2, \ldots, p_n$$$.
We will call a subarray of the permutation $$$p_l, p_{l + 1}, \ldots, p_r$$$ good if there does not exist another subarray of the same length with the same value of the minimum element in the permutation $$$p$$$.
Find the number of good subarrays of the permutation $$$p$$$.
$$$^{\text{∗}}$$$A permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2,3,1,5,4]$$$ is a permutation, but $$$[1,2,2]$$$ is not a permutation ($$$2$$$ appears twice in the array), and $$$[1,3,4]$$$ is also not a permutation ($$$n=3$$$ but there is $$$4$$$ in the array).
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). The description of the test cases follows.
The first line of each test case contains one integer $$$n$$$ ($$$1 \leq n \leq 2 \cdot 10^{5}$$$).
The second line of each test case contains $$$n$$$ distinct integers $$$p_1, p_2, \ldots, p_n$$$ ($$$1 \leq p_{i} \leq n$$$).
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.
For each test case, output the number of good subarrays in one line.
41121 243 2 4 173 7 5 1 6 4 2
13814
In the first test case, the only subarray is good.
In the second test case, all subarrays are good.
In the third test case, the subarrays $$$[p_1, p_2]$$$ and $$$[p_2, p_3]$$$ are not good, because they have the same length and the same value of the minimum element. All other subarrays are good.
| Name |
|---|


