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

#define ll long long
#define endl "\n"
#define vll vector<ll>
#define ff first
#define ss second



int main(){

    ll t,n,a,b,aa,bb,k;
    cin>>t;

    while(t--){
        cin>>n;

        vll v(n+1);
        for(int i=0;i<n;i++){
            cin>>v[i+1];
        }

        ll ans=0;

        for(int i=1;i<=n-1;i++){
            a = i+i+1;
            b = i+n;

            aa = a/v[i];
            bb = b/v[i];

            if(a%v[i]!=0)aa++;

            for(int k=aa;k<=bb;k++){
                if(v[v[i]*k-i]==k)ans++;
            }
        }

        cout<<ans<<endl;

    }

    return 0;
}