#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define endl "\n"
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define trace(x) cerr << #x << " = " << x << '\n'
using namespace std;
const double EPS = 1e-9;
const int INF = 2e9, MOD = 1e9+7;
 
int32_t main()
{
     IOS;
     int t;
     cin>>t;
     while(t--)
     {
         int n;
         cin>>n;
         int a[n+1];
         for(int i=1;i<=n;i++) cin>>a[i];
         int ans=0;
         for(int i=1;i<=n-1;i++)
         {
             for(int j=1;a[i]*j-i<=n;j++)
             {
                 int k=a[i]*j-i;
                 if(k>i&&a[k]==j) ans++;
             }
         }
         cout<<ans<<endl;
     }
return 0;
}

