Beautiful Pairs
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
- The first line contains an integer t denoting the number of testcases.
- The first line of each testcase contains an integer n denoting the number of elements in the array a.
- The second line of the each test case contains n integers - array a.
- Sum of n all over test cases does not exceed 2x105.
Output Format
For each test case output the number of beatiful pairs of indices in the array.
Constraints
- 1 \(\leq\) t \(\leq\) 104
- 1 \(\leq\) n \(\leq\) 2x105
- 1 \(\leq\) ai \(\leq\) n
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
Open on HackerRank ↗ · Markdown source · Back to the archive