# include <bits/stdc++.h>

using namespace std;

long long int a[100006];
void testcase(){
    long long int n;
    long long int count = 0;
    cin >> n;
    for (int i=0;i<n;i++){
        cin >> a[i];
    }
    for (int i=0;i<n;i++){
        if (a[i]==0){
            continue;
        }
        int j = i+1;
        if (a[i]!=1)
            j = a[i]*((i+1)/a[i]) + (a[i]-((i+1)%a[i])) - 1;
        if (j<=i){
            j += a[i];
        }
        //cout << i << "<<<<----->>>>>>" << j << endl;
        //cout << j << "J\n";
        for (;j<n;j+=a[i]){
            if (a[i]*a[j]==i+j+2){
                //cout << i << "----" << j << endl;
                count++;
            }
        }
    }
    cout << count << endl;
}

int main(){
    int t;
    cin >> t;
    while(t--){
        testcase();
    }
    return 0;
}