#include<bits/stdc++.h>
#define ll long long
#define fr(i,j,n) for(int i=j;i<n;i++)
#define deb(x,v) cout<<x<<" = "<<v<<endl
#define vi vector<int>
#define all(x) x.begin(),x.end()
using namespace std;

void arrayInput(vi& a, int n){
    fr(i,0,n) {
        cin>>a[i];
    }
}

void solve() {
	int n;
	cin>>n;
	vector<int> arr(n);
	arrayInput(arr,n);

	int limit = 2*n;
	int count = 0;
	for(int i=0;i<n;i++) {
		int a = arr[i];
		int xlimit = ceil((double)limit/a - 1);
		int xstart = ceil((double)(2*(i+1)+1)/a);
		for(int x=xstart;x<=xlimit;x++) {
			int possiblej = a*x-(i+1);
			if(possiblej <= n && arr[possiblej-1] == x)
				++count;
		}
	}
	cout<<count<<endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    #ifdef STDINSKP
        freopen("sampleInput.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    int T;
    cin>>T;
    while(T--) {
        solve();
    }
    return 0;
}
