NOI Contest Archive

Archive / 2022 / May 2022

Beautiful Pairs

Medium · National Olympiad in Informatics Sri Lanka - May 2022

You are given an array a of n integers. A pair of indices i,j is beautiful if j - i = aj - ai, where j > i. You have to count the number of beautiful pairs of indices in the array.

Input Format

Output Format

For each test case output the number of beatiful pairs of indices in the array.

Constraints

Sample Input 0

4
6
3 5 1 4 6 6
3
1 2 3
4
1 3 3 4
6
1 6 3 4 5 6

Sample Output 0

1
3
3
10