#include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; const ll MOD = 100000007; const ll N = 2000; ll pr[N], mn[N], n, g[N]; bool vis[N]; ll a[N][N]; ll b[N]; ll s[N]; void linearShaker() { for (ll i = 2; i <= 1000; i++) { if (!vis[i]) pr[++pr[0]] = i, mn[i] = pr[0]; for (ll j = 1; j <= pr[0] && i * pr[j] <= 1000; j++) { vis[i * pr[j]] = 1; mn[i * pr[j]] = j; if (i % pr[j] == 0) break; } } } ll pw(ll a, ll b) { ll re = 1; while (b) { if (b & 1) re = 1LL * re * a % MOD; a = 1LL * a * a % MOD; b >>= 1; } return re; } void Main() { scanf("%I64d", &n); memset(s, 0, sizeof s); for (ll i = 1; i <= n; i++) { ll x; scanf("%I64d", &x); for (ll i = 1; i * i <= x; i++) if (x % i == 0) { if (i * i == x) { s[i]++; } else { s[i]++; s[x / i]++; } } } /* for (ll i = 1; i <= 1000; i++) { ll j = i; memset(b, 0, sizeof b); while (j > 1) { b[mn[j]]++; j /= pr[mn[j]]; } ll s = 0; for (ll k = 1; k <= n; k++) { bool flg = 1; for (ll l = 1; l <= pr[0]; l++) if (a[k][l] < b[l]) { flg = 0; break; } s += flg; } g[i] = (pw(2, s) - 1 + MOD) % MOD; }*/ ll ans = 0; for (ll k = 1000; k >= 1; k--) { g[k] = (pw(2, s[k]) - 1 + MOD) % MOD; for (ll j = 2; j <= 1000 / k; j++) g[k] = (g[k] - g[k * j] + MOD) % MOD; ans = (ans + 1LL * (g[k]) * k % MOD) % MOD; } printf("%I64d\n", ans); } int main() { linearShaker(); ll T; scanf("%I64d", &T); while (T--) Main(); }