CitadelOA #12
Count Stable Segments
估计中等可在线判题
In a contiguous segment of length at least 3, the left and right endpoint capacities must be equal and must equal the sum of all interior capacities. Find the number of such segments. The original capacity[i] is restored to the left endpoint capacity[l] based on the following sentence and the examples.
输入格式
The first line contains n, followed by n capacity values; complete original bounds 1≤n≤100000, 1≤capacity[i]≤100000.
输出格式
Output a single integer, the answer.
样例 1
输入:
5
9 3 3 3 9
输出:
2
样例 2
输入:
7
9 3 1 2 3 9 10
输出:
2
样例 3
输入:
2
1 1
输出:
0
样例说明
The outputs of the three public examples are, in order: 2; 2; 0. These answers were verified by independent enumeration or direct simulation.