#define ll long long
#define fr first
#define sc second
#define pb(x) push_back(x)
#define nxt continue
#define sz(container) ((ll) container.size())
#define umap unordered_map
#define uset unordered_set
#define MAX LONG_LONG_MAX
#define MIN LONG_LONG_MIN
#define mkpr(f, s) make_pair(f, s)
#define el '\n'
#include <bits/stdc++.h>
using namespace std;
const ll MOD = 1e9 + 7;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
ll t, n, mx, c, ans, i;
// ll freq[(ll) 1e5 + 1];
ll in[(ll) 1e5], sm[(ll) 1e5 + 1];
cin >> t;
while (t--) {
cin >> n;
mx = MIN, ans = 0;
// memset(freq, 0, sizeof freq);
memset(sm, 0, sizeof sm);
for (i = 0; i < n; ++i) {
cin >> in[i];
// ++freq[in[i]];
mx = max(mx, in[i]);
sm[in[i]] += n - i;
}
for (i = 0; i < n - 1; ++i) {
// --freq[in[i]];
sm[in[i]] -= n - i;
c = in[i];
while (c <= mx) {
// if (sm[c])
ans += (i + 1) * sm[c];
c += in[i];
}
}
cout << ans << el;
}
return 0;
}
Copy