CF2047A.Alyona and a Square Jigsaw Puzzle

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Alyona and a Square Jigsaw Puzzle

Alyona assembles an unusual square Jigsaw Puzzle. She does so in nn days in the following manner:

  • On the first day, she starts by placing the central piece in the center of the table.
  • On each day after the first one, she places a certain number of pieces around the central piece in clockwise order, always finishing each square layer completely before starting a new one.

For example, she places the first 1414 pieces in the following order:

The colors denote the layers. The third layer is still unfinished.

Alyona is happy if at the end of the day the assembled part of the puzzle does not have any started but unfinished layers. Given the number of pieces she assembles on each day, find the number of days Alyona is happy on.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t5001 \le t \le 500). The description of the test cases follows.

The first line contains a single integer nn (1n1001 \le n \le 100), the number of days.

The second line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1ai1001 \le a_i \le 100, a1=1a_1 = 1), where aia_i is the number of pieces Alyona assembles on the ii-th day.

It is guaranteed in each test case that at the end of the nn days, there are no unfinished layers.

Output

For each test case, print a single integer: the number of days when Alyona is happy.

Note

In the first test case, in the only day Alyona finishes the only layer.

In the second test case, on the first day, Alyona finishes the first layer, and on the second day, she finishes the second layer.

In the third test case, she finishes the second layer in a few days.

In the fourth test case, she finishes the second layer and immediately starts the next one on the same day, therefore, she is not happy on that day. She is only happy on the first and last days.

In the fifth test case, Alyona is happy on the first, fourth, and last days.

Samples

5
1
1
2
1 8
5
1 3 2 1 2
7
1 2 1 10 2 7 2
14
1 10 10 100 1 1 10 1 10 2 10 2 10 1
1
2
2
2
3

在线编程 IDE

建议全屏模式获得最佳体验