#include<bits/stdc++.h>

using namespace std;

/* User Template
@Shaurya Gautam
CP.cpp */

/*****************************************/

#define ll long long
#define vb vector<bool>
#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>
#define vpii vector<pair<int, int>>
#define vc vector<char>
#define pii pair<int, int>
#define mp make_pair
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FR(i,L,R) for (int i = L; i > R; i--)
#define FRE(i,L,R) for (int i = L; i >= R; i--)
#define pb push_back
#define ppb pop_back
#define endl "\n"

class my_compare{
    public:
        bool operator()(pii &p1, pii &p2){
            return p1.second < p2.second;
        }
};


/*************************************************/
void solve(){
    int n;
    cin >> n;

    vi arr(n + 1);
    FE(i, 1, n){
        cin >> arr[i];
    }

    int ans{0};

    FE(i, 1, n){
        if(arr[i] > 2*i - 1) continue;
        
        int j = (arr[i] > i) ? 1 : (i/arr[i]) + 1;
        while(j*arr[i] <= 2*i - 1){
            if(arr[j*arr[i] - i] == j) ans++;
            j++;
        }
    }

    cout << ans << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    bool test_case{1}, fileop{0};

    if(fileop){
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    }

    int t;
    if(test_case){
        cin >> t;
        F(i, 0, t){
            solve();
        }
    }
    else solve();
}

/* 
Some Learnings-
     -Don't focus on ratings or standings
     -See problem from new perspective and forget current thoughts 
     -Accuracy is important, be sure that you think right
     -Speed builds up once accuracy does... solve as many questions as possible 
     -Editorial is last resort... don't jump to it
     -BE CONSISTENT
     -My two brothers - Hard Work and Perseverance
     -Never leave a contest, no matter how tough it might be
*/