#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--)
{
int n, x;
cin >> n;
vector<int> pos(1e5 + 1, 0);
for (int i = 1; i <= n; i++)
{
cin >> x;
pos[x] = i;
}
ll ans = 0;
for (int i = 1; i <= 1e5; i++)
{
if (pos[i])
{
for (int j = i + i; j <= 1e5; j += i)
{
if (pos[j] > pos[i])
{
ans += ((ll)pos[i] * (ll)(n - pos[j] + 1));
}
}
}
}
cout << ans << "\n";
}
return 0;
}
Copy