#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){

	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int t;
	cin >> t;
	while(t--) {
        ll n, res = 0;
        cin >> n;
        vector <ll> v(n + 1);
        for(int i = 1; i <= n; i++)
            cin >> v[i];
        for(int i = 1; i < n; i++) {
            ll mod = v[i] - i, st;
            if(mod <= 0)
                st = v[i] - (abs(mod) % v[i]);
            else
                st = mod;
            if(st <= i) {
                ll a = st % v[i], b = i % v[i];
                if(a == b)
                    st = i + v[i];
                else if(a < b)
                    st = i + (v[i] - b + a);
                else
                    st = i + (a - b);
            }
            for(int j = st; j <= n; j += v[i]) {
                if(v[i] * v[j] == i + j)
                    res++;
            }
        }
        cout << res << "\n";
	}

	return 0;
}
