// If you're hacking me, at least subscribe to my channel at:
// https://www.youtube.com/user/ivanvlahov922

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

const int MOD = 1e9+7;
const double DEG2RAD = 0.017453292;
const double RAD2DEG = 57.29578049;


int main(){

    #ifdef DEBUG
        freopen("..\\input.txt", "r", stdin);
        clock_t tStart = clock();
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int TEST = 1;
    cin >> TEST;

    for(; TEST; TEST--){
        // Don't forget to clear global variables if you use them
        int n;
        cin >> n;

        vector<pair<ll, ll>> sp;
        for(int i=0; i<n; i++){
            ll x;
            cin >> x;

            sp.push_back({x, i+1});
        }

        sort(sp.begin(), sp.end());

        ll res = 0;

       

        for(int i=0; i<n; i++) {
            for(int j=i+1; j<n; j++) {
                if(sp[i].first * sp[j].first >= 2*n) break;

                if(sp[i].first * sp[j].first == sp[i].second + sp[j].second) {
                    // cout << sp[i].first << " " << sp[j].first << endl;
                    res++;
                }
            }
        }
        

        cout << res;
        
        
        cout << "\n";
    }

    // Use formatted output if the result is float or double

    #ifdef DEBUG
        printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    #endif

    return 0;
}