Problem list
Log in
#coci00265 · COCI 2012/2013 Contest 6

Dobri

Gold III 1.0 s 32 MB

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

Input
2
1 3
Output
1

Example 2

Input
6
1 2 3 5 7 10
Output
4

Example 3

Input
3
-1 2 0
Output
1
Source
COCI 2012/2013 Contest 6
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code