Middle equals the sum of its neighbours
Count the groups of three consecutive elements where the first plus the third equals the middle one.
Reported in: Cognizant GenC (memory-based)
Input
First line: N. Second line: N integers.
Output
The number of such groups.
Constraints
1 ≤ N ≤ 10^5.
Example 1
Input:
5
1 3 2 -1 -3
Output:
3Example 2
Input:
4
1 1 1 1
Output:
0Hint: Check a[i] + a[i+2] == a[i+1] for every i from 0 to N−3.