400548: GYM100203 G Good elements
Memory Limit:64 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
G. Good elementstime limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard output
You are given a sequence A consisting of N integers. We will call the i-th 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 ( - 105 ≤ Ai ≤ 105).
OutputThe first and only line of output must contain the number of good elements in the sequence.
ExamplesInput2Output
1 3
1Input
6Output
1 2 3 5 7 10
4Input
3Output
-1 2 0
1