#define _CRT_SECURE_NO_WARNINGS
/* To Be or Not To Be !!
Allah Almost3aan
Make it happens :) */
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll OO = 1e18, oo = 1e12 + 21;
#define ed '\n'
#define EPS 1e-10
#define PI acos(-1.0)
#define sz(a)a.size()
#define vi vector<int>
#define pii pair<int,int>
#define all(c)c.begin(),c.end()
#define RT(v)return cout<<v<<ed,0
#define rall(s)s.rbegin(),s.rend()
#define stpr(n)fixed<<setprecision(n)
int di[8] = { 0, 0, 1, -1, -1, 1, -1, 1 };
int dj[8] = { 1, -1, 0, 0, 1, 1, -1, -1 };
#define show(x)cout<<"> "<<(#x)<<" = "<<x<<ed
#define reset(mem,val)memset(mem,val,sizeof mem)
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
string ys = "YES", no = "NO";
const long double dgr = acos(-1) / 180, rad = 180 / acos(-1);
const ll mod = 1e9 + 7, N = 4e5 + 5, M = 5005;

int frq[N];

int main(){

	fast;

	int t; cin >> t;
	while (t--){
		ll n; cin >> n;
		vi v(n+1);

		for (int i = 1; i <= n; i++){
			cin >> v[i];
			frq[v[i]] = i;
		}
		int ans = 0;
		for (int i = 1; i <= 4*n; i++){
			for (int j = 1; j*j <= i; j++){
				if (i%j == 0&&j!=(i/j)){
					if (frq[j]&&frq[i/j]&&((frq[j] + frq[i / j]) == i))ans++;
				}
			}
		}
		cout << ans << ed;
		for (int i = 1; i <= n; i++)
			frq[v[i]] = 0;
		
	}
}