//Esraa_Taha
//إن مررت من هنا فأدع لي
#include <bits/stdc++.h>
using namespace std;
#define zrebeooo ios_base::sync_with_stdio(false);cin.tie(NULL);
#define zrebeooo2 cin.tie(0); cin.sync_with_stdio(0);
#define ll long long
#define sz(x) (int)x.size()
#define pb push_back
#define pf push_front
#define po pop_back
#define pi acos(-1) //radian
#define eu(s) s.erase(unique(be(s)),s.end())
#define fs(n) fixed<<setprecision(n)
#define vi vector<int>
#define vl vector<ll>
#define el '\n'
#define S second
#define F first
#define be(s) (s).begin() , (s).end()
#define clr(x , v) memset(x , v , sizeof(x))
#define sz2(a) sizeof((a))/sizeof((a[0]))
#define ln(i,k,n) for (int i=n ; i>=k ; i--)
#define l(i,k,n) for (int i=k ; i<n ; i++)
#define loop(it , s) for (it= s.begin() ; it != s.end() ; it++)
#define loopr(it , s) for (it= s.rbegin() ; it != s.rend() ; it++)
#define M 1000000007
#define test int t; cin>>t; while(t--)
//======================================================
ll gcd(ll a, ll b) //O(log(min(a,b)))
{
return (b ? gcd (b, a%b) : a);
}
ll lcm(ll a, ll b)
{
return (a / gcd(a, b))*b;
}
ll egcd(ll a, ll b, ll& x,ll& y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
ll x1, y1;
ll d = egcd(b, a % b, x1, y1);
x = y1;
y = x1 - y1 * (a / b);
return d;
}
//=======================================================
void input()
{
#ifndef ONLINE_JUDGE
freopen("input.in", "r", stdin);
#endif
}
//======================================================
/*int dx[] = { -1, 0, 0, 1, -1, -1, 1, 1}; //j
int dy[] = { 0, 1, -1, 0, -1, 1, 1, -1}; //i*/
//======================================================
ll mulmod(ll a , ll b , ll mod) {
if(a>b) return mulmod(b,a,mod);
ll x = 0, y = a % mod;
while (b) {
if (b&1) {
x = (x%mod + y%mod)%mod;
}
y = (y <<= 1)%mod;
b >>= 1;
}
return x%mod;
}
//======================================================
ll power(ll b , ll p , ll m){
ll an=1;
while(p){
if(p&1){
an*=b;
an%=m;
}
b*=b;
b%=m;
p >>= 1;
}
return an%m;
}
//======================================================
/*vector<bool> is_prime;
vl s;
void sieve(ll n) {
is_prime.assign(n+1, true);
is_prime[0] = is_prime[1] = 0;
for(ll i=4 ; i<=n ; i+=2) is_prime[i]=0;
for (ll i = 3 ; i*i <= n ; i+=2){
if (is_prime[i])
for (ll j = i * i; j <= n; j += i) is_prime[j] = 0;
}
l(i , 2 , n+1) if(is_prime[i]) s.pb(i);
}*/
//======================================================
void linearsieve(int n){
vi pr;
vector<bool> lp(n+1 , 0);
for (int i=2; i <= n; ++i) {
if (lp[i] == 0) {
pr.push_back(i);
}
for (int j=0; j < (int)pr.size() && pr[j] <= lp[i] && i*pr[j] <= n; ++j) {
lp[i * pr[j]] = 1;
}
}
}
//======================================================
vector<ll> primedivs(ll N){
vector<ll> primeDivs[N];
for (ll i = 2; i <= N; i++) {
if(sz(primeDivs[i])) continue;
for (ll j = i; j <= N; j += i)
primeDivs[j].pb(i);
}
return primeDivs[N];
}
//======================================================
vector<int> d[100001];
int main ()
{
zrebeooo zrebeooo2
//input();
//مهما الدنيا إتنيلت ضلمت لازم يبقى عندك زفت أمل و تعرف إن في نور في أخر أم النفق//
//THINK TWICE .. CODE ONCE//
//ACPC//
//فاكس؟ فاكس//
l(i , 1 , 100001){
for(ll j=1 ; j*j<=i ; j++){
if(i%j==0){
d[i].pb(j);
if(i/j != j) d[i].pb(i/j);
}
}
}
test{
ll n;
cin>>n;
ll ans=0;
map<ll,vector<ll>> m;
l(i , 0 , n){
int x; cin>>x; m[x].pb(i);
}
map<pair<int,int>,int> p;
for(auto i:m){
l(u , 0 , sz(d[i.F])){
l(k , 0 , sz(m[d[i.F][u]])){
l(h , 0 , sz(i.S)){
ll x = m[d[i.F][u]][k] , y = i.S[h];
if(x<y && p[{x,y}]==0) ans += (x+1)*(n-y) , p[{x,y}]=1;
}
}
}
}
cout<<ans<<el;
}
return 0;
}
Copy