#include <bits/stdc++.h>
using namespace std;

int main() {
	int t; cin>>t;
	while(t--){
		int n; cin>>n;
		vector<int> v(n);
		for(int& i: v) cin>>i;
		int j=1;
		int cnt = 0;
		while(j<=n){
			int s = (j/v[j-1] + 1) * v[j-1];
			while(s < 2*j) {  int i = (s-j); int expval = s/v[j-1]; if(expval == v[i-1]) cnt++;  s+=v[j-1];}
			j++;
		}
		cout<<cnt<<endl;
	}
	return 0;
}