#include<bits/stdc++.h>
////#include "cmake-build-debug/Car.h"
using namespace std;
#define endl '\n'
#define ll long long
const int N = 2e5 + 5 ;
void fast() {
std::ios_base::sync_with_stdio(0);
cin.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("Input.txt", "r", stdin);
freopen("Output.txt", "w", stdout);
#endif
}
vector<int> divs[N];
void generateDivisors(int n) {
for (int i = 1; i <= n; ++i){
for (int j = i; j <= n; j += i)
divs[j].push_back(i);
}
}
int main() {
fast() ;
generateDivisors(100000) ;
int t ;
cin>>t ;
while (t--)
{
int n ;
cin>>n ;
vector<int>a(n) ;
for (int i=0 ;i<n;i++)
{
cin>>a[i] ;
}
ll ans = 0 ;
map<int,ll>MP ;
for (int i = 0 ; i < n ; i++ )
{
vector <int> cur = divs[a[i]] ;
for (int j= 0 ;j<cur.size() ;j++)
{
ans += MP[cur[j]] * (n-i) ;
}
MP[a[i]]+=(i+1) ;
}
cout << ans << endl ;
}
return 0 ;
}
Copy