Epic Subarrays Counting#12271

Epic Subarrays Counting

1 second
256 megabytes
Easy

Given an array of integers, determine the count of epic subarrays.

An array is called epic if its product is strictly increasing in each step of multiplying. Formally, we call a subarray a_l, a_{l+1}, \ldots, a_r to be strictly interesting at each step if and only if

a_l < a_l \cdot a_{l+1} < a_l \cdot a_{l+1} \cdot a_{l+2} < \ldots < a_l a_{l+1} \ldots a_r

Input

The first line contains single integer (1 \le t \le 10^4) — the number of test cases.

The first line of each test case contains single integer (1 \le n \le 10^5) — the length of array .

The second line of each test case contains separated integers a_1, a_2, \ldots, a_n (1 \le a_1, a_2, \ldots, a_n \le 2) — the array .

It's guaranteed that \sum n \le 10^5 overall tests.

Output

For each test case output single integer — the number of epic subarrays.

Please note! that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).

Examples

Example

Input
1
3
1 2 2
Output
6

Example 1

Loading
Loading

Note

In the first test case, the epic subarrays are:

  • , , because the array is single element so it's trivially increasing.

  • is increasing because 1 < 1 \cdot 2.

  • is increasing because 2 < 2^2.

  • [1, 2, 2] is increasing because 1 < 2 < 2^2.

Thus the count is .

Scoring

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

  2. Subtask ( points): a_1 = a_2 = \ldots = a_n

  3. Subtask ( points): No additional constraints.