#include <bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define rng(x) x.begin(), x.end()
#define IOS ios_base::sync_with_stdio(false)
#define endl "\n"
//----------SOLUTION----------
const int mod = 1000000007;
void solve()
{
    int n;
    cin >> n;
    vi a(n + 1);
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    int cnt = 0;
    for (int i = 1; i <= n; i++)
    {
        for (int j = a[i] - i; j <= n; j += a[i])
        {
            if (j >= 0)
            {
                if (a[i] * a[j] == i + j && i < j)
                    cnt++;
            }
        }
    }
    cout << cnt << endl;
}

bool google = false;
//----------MAIN----------
int32_t main()
{
    IOS;
    cin.tie(0);
    cout.tie(0);
    int t = 1, mn = 1;
    bool tc = true;
    if (tc)
        cin >> t;
    google = false;
    while (t--)
    {
        if (google)
            cout << "Case #" << mn++ << ": ";
        solve();
    }
    return 0;
}

/*:::: Notes ::::

1) To check whether a number n is a power of 2 or not 
just do n&(n-1)
if it is 0 then ans is yes else no

2) To calculate fibonacci number in logN time use
matrix exponentiation which is similar to binary
exponentiation
*/