#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define IN insert
#define ALL(a) a.begin(),a.end()
typedef long long int ll;


int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output56.txt", "w", stdout);
#endif

	ll t; cin >> t;
	while (t--) {
		ll n; cin >> n;
		ll a[n + 1];
		for (int i = 0; i < n; i++) {
			cin >> a[i + 1];
		}
		ll ans = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = a[i] - i; j <= n; j += a[i]) {
				if (j > i && a[i]*a[j] == i + j)ans++;
			}
		}
		cout << ans << endl;
	}
}