#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
typedef long long ll;
int T, n, v[N];
map<int, ll> mp;
ll ans;
int main() {
scanf("%d",&T);
while(T--) {
scanf("%d", &n);
mp.clear();
ans=0;
for(int i=0; i<n; ++i) {
scanf("%d", &v[i]);
for(int j=1; j*j <= v[i]; ++j) {
if(v[i] % j == 0) {
ans += mp[j] * (n-i);
if(j != v[i]/j)
ans += mp[v[i]/j] * (n-i);
}
}
mp[v[i]] += i+1;
}
printf("%lld\n", ans);
}
}