#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#define mod 1000000007
#define ll long long int
using namespace std;
int main()
{
    ll t; cin >> t;
    while(t--)
    {
        ll n; cin >> n;
        ll a[n+1];
        a[0]=-1;
        for(ll i=1;i<=n;i++)
            cin >> a[i];
        ll ans=0;
        for(ll i=1;i<=n;i++)
        {
            for(ll j=a[i];j<=n+i;j+=a[i])
            {
                ll x=j-i;
                if(x<=i) continue;
                if((a[x]*a[i])==j)
                ans++;
            }
        }

        cout<<ans<<endl;
    }
    return 0;
}