#include<bits/stdc++.h>
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0);
#define pb                push_back
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define ll                long long
#define pii               pair<int,int>
using namespace std ;

void solve()
{
    ll n , cnt = 0; cin >> n ;
    ll a[n+1] ;
    vector< pair < ll , ll > > v ;
    for(ll i=1 ; i<=n ;i++){
        cin >> a[i] ;
        v.pb({a[i],i}) ;
    }
    sort(all(v)) ;
    for(ll i=n-1 ; i>=0 ; i--){
        for(ll j=0 ; j<i ;j++){
            if(v[i].fr*v[j].fr == v[i].sc+v[j].sc){
                cnt++ ;
            }
            if(v[i].fr*v[j].fr>=2*n) break ;
        }
    }
    cout << cnt << endl ;
}

signed main(){
    FastIO ;
    int t=1 ;
    cin>>t ;
    while(t--){
        solve() ;
    }
    return 0 ;
}

