Dobri
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 ith 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?
InputThe first line of input contains the positive integer N (1 ≤ N ≤ 5000), the length of the sequence A. The second line of input contains N space-separated integers representing the sequence A (-100 000 ≤ Ai ≤ 100 000).
OutputThe first and only line of output must contain the number of good elements in the sequence.
Input
Output
6
1 2 3 5 7 10 Output
4Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.