传统题 1000ms 256MiB

Good Prefixes

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Problem

Alex thinks some array is good if there exists some element that can be represented as the sum of all other elements (the sum of all other elements is 00 if there are no other elements). For example, the array [1,6,3,2][1,6,3,2] is good since 1+3+2=61+3+2=6. Furthermore, the array [0][0] is also good. However, the arrays [1,2,3,4][1,2,3,4] and [1][1] are not good.

Alex has an array a1,a2,,ana_1,a_2,…,a_n. Help him count the number of good non-empty prefixes of the array aa. In other words, count the number of integers i(1in)i(1≤i≤n) such that the length ii prefix (i.e.a1,a2,,ai)(i.e.a_1,a_2,…,a_i) is good.

Input

The first line of the input contains a single integer t(1t104)t(1≤t≤10^4) — the number of test cases.

The first line of each test case contains a single integer n(1n2105)n(1≤n≤2⋅10^5) — the number of elements in the array.

The second line of each test case contains nn integers a1,a2,,an(0ai109)a_1,a_2,…,a_n(0≤a_i≤10^9) — the elements of the array.

It is guaranteed that the sum of n over all test cases does not exceed 2105.2⋅10^5.

Output

For each test case, output a single integer — the number of good non-empty prefixes of the array a.a.

Example : in

7
1
0
1
1
4
1 1 2 0
5
0 1 2 1 4
7
1 1 0 3 5 2 12
7
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 294967296
10
0 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 589934592

Example : out

1
0
3
3
4
1
2

Note

In the fourth test case, the array has five prefixes:

  • prefix [0][0] is a good array, as mentioned in the statement;

  • prefix [0,1][0,1] is not a good array, since 010≠1;

  • prefix [0,1,2][0,1,2] is not a good array, since 01+2,10+20≠1+2, 1≠0+2 and 20+1;2≠0+1;

  • prefix [0,1,2,1][0,1,2,1] is a good array, since 2=0+1+12=0+1+1 ;

  • prefix [0,1,2,1,4][0,1,2,1,4] is a good array, since 4=0+1+2+1.4=0+1+2+1.

As you can see, three of them are good, so the answer is 3.3.

前缀和 x 2

未参加
状态
已结束
规则
ACM/ICPC
题目
9
开始于
2024-11-13 19:00
结束于
2024-11-13 22:00
持续时间
3 小时
主持人
参赛人数
6