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

#define fr(i, a, b) for(int i = a; i < b; ++i)
#define rf(i, a, b) for(int i = a - 1; i >= b; --i)
#define len(v) size(v)
#define all(v) begin(v), end(v)
#define int long long
#define ff first
#define ss second
#define ii pair<int, int>
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define ts to_string

template<typename A, typename B> A amax(A &a, B b) {a = max(a, b); return a;}
template<typename A, typename B> A amin(A &a, B b) {a = min(a, b); return a;}
template<typename A, typename B> string ts(pair<A, B> p);
string ts(const string& s) {return '"' + s + '"';}
string ts(const char* s) {return ts((string)s);}
template<typename A> string ts(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false, res += ts(x);
    }
    res += "}";
    return res;
}
template<typename A, typename B> string ts(pair<A, B> p) {
    return "(" + ts(p.ff) + ", " + ts(p.ss) + ")";
}
void debug_out() {cerr << "\n";}
template<typename H, typename... T> void debug_out(H h, T... t) {
    cerr << " " << ts(h);
    debug_out(t...);
}

#ifdef LOCAL
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) 
#endif

const int INF = 0x3f3f3f3f3f3f3f3fll;
const int MOD = 1e9 + 7; 
const int N   = 1e6 + 5;

void solve() {  
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    fr(i, 0, n) {
        cin >> a[i].ff;
        a[i].ss = i + 1;
    }
    sort(all(a));

    int ans = 0;
    fr(i, 0, n) {
        int n1 = a[i].ff, i1 = a[i].ss;
        fr(j, i + 1, n) {
            int n2 = a[j].ff, j1 = a[j].ss;
            if(n1 * n2 > 2 * n) break;
            if(n1 * n2 == i1 + j1) {
                ans++;
            }
        }
    }

    cout << ans << "\n";

}

int32_t main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(nullptr);

    int t = 0;
    if(!t) cin >> t;
    while(t--) solve();
} 