#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include<functional>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include<iterator>
#include <stdio.h>
#include <string.h>
#define T int t=0;cin>>t;while(t--)
#define F(i,n) for(int i=0;i<n;i++)
#define fo(i,a)for(auto&i:a)
#define all(a) a.begin(),a.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define ll long long
#define ld long double
#define endl "\n"
#define vl vector<ll>
#define vi vector<int>
#define cost first
#define from second.first
#define to second.second
#define sz(X) X.size()
using namespace std;
const ll mod = 1000000007;
void code();
///*-*-*-*-*-*-*-*-*-*-*-*-*-*-*>> # str main # <<*-*-*-*-*-*-*-*-*-*-*-*-*-*-*///
ll mp[100005]={0};
int main()
{
code();
vector<vi>di(100005);
for(int i=1;i<100005;i++)
{
for(int j=i;j<100005;j+=i)di[j].push_back(i);
}
T
{
int n;
ll sum=0;
cin>>n;
vi a(n);
F(i,n)
{
cin>>a[i];
fo(j,di[a[i]])
{
sum+=(mp[j]*(n-i));
}
mp[a[i]]+=i+1;
}
fo(i,a)mp[i]=0;
cout<<sum<<endl;
}
}
///*-*-*-*-*-*-*-*-*-*-*-*-*-*-*>> # end main # <<*-*-*-*-*-*-*-*-*-*-*-*-*-*-*///
void code()
{
std::ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cout << fixed << setprecision(6);
}
Copy