#include <bits/stdc++.h>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // freopen("kext.inp", "r", stdin);
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<pair<int, int>> a(n+1);
        for(int i=1; i<=n; ++i){
            cin >> a[i].first;
            a[i].second = i;
        }
        sort(a.begin(), a.end());
        int ans = 0;
        for(int i=1; i<=n && a[i].first * a[i].first <= 2 * n; ++i){
            for(int j=i+1; j<=n && a[i].first * a[j].first <= 2 * n; ++j){
                if(a[i].first * a[j].first == a[i].second + a[j].second) ans++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}
