#abc417C. Distance Indicators

Distance Indicators

题目描述

You are given an integer sequence A=(A1,A2,,AN)A=(A _ 1,A _ 2,\ldots,A _ N) of length NN.

Find how many pairs of integers (i,j) (1i<jN)(i,j)\ (1\le i\lt j\le N) satisfy ji=Ai+Ajj-i=A _ i+A _ j.

输入格式

The input is given from Standard Input in the following format:

NN

A1A_1 A2A_2 \ldots ANA_N

输出格式

Output the answer.

样例

9
3 1 4 1 5 9 2 6 5
3

For example, when (i,j)=(4,7)(i,j)=(4,7), we have ji=74=3j-i=7-4=3 and Ai+Aj=1+2=3A _ i+A _ j=1+2=3, so ji=Ai+Ajj-i=A _ i+A _ j.

In contrast, when (i,j)=(3,8)(i,j)=(3,8), we have ji=83=5j-i=8-3=5 and Ai+Aj=4+6=10A _ i+A _ j=4+6=10, so jiAi+Ajj-i\ne A _ i+A _ j.

Only the three pairs (i,j)=(1,9),(2,4),(4,7)(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

数据范围与提示

  • 1N2×1051\le N\le2\times10 ^ 5
  • 1Ai2×105 (1iN)1\le A _ i\le2\times10 ^ 5\ (1\le i\le N)
  • All input values are integers.