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

#define ar array
#define ll long long

const int MAX_N = 1e5 + 1;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;



void solve() 
{
	ll n;
	cin>>n;
	pair<ll,ll> arr[n];
	for(ll i=0; i<n; i++)
	{
		cin>>arr[i].first;
		arr[i].second = i+1;
	}
	sort(arr,arr+n);
	ll ctr = 0;
	for(ll i=0; i<n; i++)
	{
		for(ll j=i+1; j<n; j++)
		{
			ll val = arr[i].first * arr[j].first;
			if(val > 2*n)
				break;
			if(val == arr[i].second + arr[j].second)
				ctr++;
		}
	}
	cout << ctr << endl;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif   
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll tc = 1;
    cin >> tc;
    for (ll t = 1; t <= tc; t++) 
    {
        solve();
    }
}