| CerealCodes III Novice Division |
|---|
| Finished |
You are given an permutation $$$a$$$ of length $$$n$$$ which will consist of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$.
How many pairs $$$(i, j)$$$ are there such that $$$a_i + a_j = a_{i + a_j}$$$?
The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 2 \cdot 10^5$$$).
The second line contains $$$n$$$ space separated integers $$$a_1, a_2 \dots a_n$$$ ($$$1 \leq a_i \leq n$$$). It is guaranteed these numbers are all distinct and thus form a permutation of length $$$n$$$.
Output a single integer, which is the number of pairs that satisfy the conditions stated. Note that the answer might not fit into $$$32$$$ bits.
5 3 4 1 2 5
2
For the first testcase, the first pair that works is $$$(i, j) = (1, 3)$$$ since $$$a_1 + a_3 = a_{1 + 1} = 4$$$. The second pair is $$$(i, j) = (3, 3)$$$ since $$$a_3 + a_3 = a_{3 + 1} = 2$$$.
| Name |
|---|


