Authors: Ivan Mandura
You are given a sequence A consisting of N integers (not to be confused with the sequence from the previous task). We will call the i^{th} sequence element good if it equals the sum of some three elements in positions strictly smaller than i (an element can be used more than once in the sum). How many good elements does the sequence contain?
Input
The first line of input contains the positive integer N ($1 \le N \le 5000$), the length of the sequence A. The second line of input contains N space-separated integers representing the sequence A (-100 000 ≤ $A_{i} \le 100,000$).
Output
The first and only line of output must contain the number of good elements in the sequence.
Constraints
In test data worth at least 40% of total points, $N \le 50$. In test data worth at least 70% of total points, $N \le 500$.
Example 1
2 1 3
1
Example 2
6 1 2 3 5 7 10
4
Example 3
3 -1 2 0
1
Discussion
Threads about this problem. Spoilers are collapsed; wrap hints in
||double bars||.No discussion yet. Start a thread if something here needs explaining.