Codeforces Round 990 (Div. 2)
A
Alyona and a Square Jigsaw Puzzle
Codeforces
800
原题
←B →
翻译中…

Alyona assembles an unusual square Jigsaw Puzzle. She does so in $n$ 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 $14$ pieces in the following order:

翻译中…

image 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 $t$ ($1 \le t \le 500$). The description of the test cases follows.

翻译中…

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

翻译中…

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 100$, $a_1 = 1$), where $a_i$ is the number of pieces Alyona assembles on the $i$-th day.

翻译中…

It is guaranteed in each test case that at the end of the $n$ 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.

翻译中…

样例

Input #1
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
Output #1
1
2
2
2
3
InputCopy OutputCopy
题目信息
题号
2047A
时间限制
1 s
内存限制
256 MB
标签
模拟
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。