Question
Index Match

Zara has an array B of size M. Count the number of index pairs (p, q) where p < q and Bp - p = Bq - q.

Input
The first line of the input contains a single integer M.
The second line of the input contains M space-separated integers.
Output
Print the count of number of pairs of indices (p, q) in the given array B such that p < q and Bp - p = Bq - q.
Example
Sample Input
4
1 3 3 4
Sample Output
3
Explanation
The three pairs of indices are:
(1, 3) -> B[1] - 1 = B[3] - 3 -> 1 - 1 = 3 - 3 -> 0 = 0
(1, 4) -> B[1] - 1 = B[4] - 4 -> 1 - 1 = 4 - 4 -> 0 = 0
(3, 4) -> B[3] - 3 = B[4] - 4 -> 3 - 3 = 4 - 4 -> 0 = 0

Online