CF2196B Another Problem about Beautiful Pairs

Description

In the array $ a $ , we call a pair of indices $ i $ , $ j $ beautiful if the following condition holds: - $ a_{i} \cdot a_{j} = j - i $ . Count the number of beautiful pairs in the array $ a $ .

Input Format

Each test contains multiple test cases. The first line contains the number of test cases $ t $ ( $ 1 \le t \le 10^4 $ ). The description of the test cases follows. The first line of each test case contains a single integer $ n $ ( $ 2 \le n \le 2 \cdot 10^{5} $ ). The second line of each test case contains $ n $ integers $ a_{i} $ ( $ 1 \le a_{i} \le 10^{9} $ ). Additional constraints on the input: - The sum of $ n $ across all test cases does not exceed $ 2 \cdot 10^5 $ .

Output Format

For each test case, output a single integer — the answer to the problem.

Explanation/Hint

In the first example, there are $ 3 $ beautiful pairs: ( $ 1, 2 $ ), ( $ 1, 3 $ ), and ( $ 1, 5 $ ). In the second example, there are $ 7 $ beautiful pairs: ( $ 1, 3 $ ), ( $ 1, 5 $ ), ( $ 2, 4 $ ), ( $ 2, 6 $ ), ( $ 3, 4 $ ), ( $ 3, 5 $ ), and ( $ 4, 6 $ ).