Kaosar and Segments#12325

Kaosar and Segments

1 second
256 megabytes
Easy

You are given a permutation of the integers from to . Determine the number of contiguous segments whose is smaller than the main permutations .

Formally , count how many subarrays of the array since the count can be very large print it modulus 9973 where is permutation of \{1,2,3,..,n\} such that

\max(p_i,p_{i+1},p_{i+2},...,p_j) \neq \max(p_1,p_2,p_3,..,p_n)

Input

First line of input will contain a single integer (1\le t\le 10^4) denoting the number of test cases.

The first line of each test case contains two lines of input in first line a integer (1\le n\le 10^5) — the length of permutation .

The second line contains a sequence of integer p_1,p_2,p_3,...,p_n where (1\le p_i\le n) and (p_i \neq p_j; i \neq j).

It's guaranteed that \sum n \le 10^5 holds overall test cases

Output

Print the total number of segment that satisfy the condition mod 9973.

Examples

Example 1

Loading
Loading

Note

In second test case the possible segments are so the answer is .

Scoring

  • Subtask ( points) : (1 \le \sum n \le 100)

  • Subtask ( points) : (1 \le \sum n \le 1000)

  • Subtask ( points) : No additional constraints