题目描述
You are given an integer sequence A=(A1,A2,…,AN) of length N.
Find how many pairs of integers (i,j) (1≤i<j≤N) satisfy j−i=Ai+Aj.
输入格式
The input is given from Standard Input in the following format:
N
A1 A2 … AN
输出格式
Output the answer.
样例
9
3 1 4 1 5 9 2 6 5
3
For example, when (i,j)=(4,7), we have j−i=7−4=3 and Ai+Aj=1+2=3, so j−i=Ai+Aj.
In contrast, when (i,j)=(3,8), we have j−i=8−3=5 and Ai+Aj=4+6=10, so j−i=Ai+Aj.
Only the three pairs (i,j)=(1,9),(2,4),(4,7) satisfy the condition, so output 3
.
3
123456 123456 123456
0
30
8 3 6 4 9 6 5 6 5 6 3 4 7 3 7 4 9 8 5 8 3 6 8 8 4 5 5 5 6 5
17
数据范围与提示
- 1≤N≤2×105
- 1≤Ai≤2×105 (1≤i≤N)
- All input values are integers.