#include <bits/stdc++.h>
using namespace std;
const int MAX = 200005;
int arr[MAX];
int main(){
    int t;
    cin >> t;
    while(t--){
    int n;
    cin >> n;
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        cin >> arr[i];
    }

    for(int i = 1; i <= n; i++){
        for(int j = ((i+arr[i])/arr[i])*arr[i]-i; j < i; j += arr[i]){
            if( ((arr[i]*arr[j]) == (i+j))  ){
                cnt++;
            }
        }
    }

    cout << cnt << endl;}
}


