#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define x first
#define y second
#define all(v) v.begin(),v.end()
#define clr(v,d) memset(v,d,sizeof(v));
const int N = 1e5 + 10;
const ll mod = 1e9 + 7;
int n , a[N];
vector<int> divi[N];
ll oc[N];
int main()
{
cin.tie(0);
cin.sync_with_stdio(0);
for(int i = 1 ; i <= 1e5 ; i++)
{
for(int j = i ; j <= 1e5 ; j+=i) divi[j].push_back(i);
}
int t = 1 ;
cin >> t ;
while(t--)
{
cin >> n ;
ll ans = 0;
for (int i = 0; i < n; ++i) {
cin >> a[i] ;
for(int ch : divi[a[i]])
{
ans += (n-i)*oc[ch];
}
oc[a[i]] += i+1 ;
}
cout << ans << "\n" ;
for (int i = 0; i < n; ++i) {
oc[a[i]] = 0;
}
}
return 0;
}
Copy