//Awwawa! Dis cold yis ratten buy tEMMIE! #include #define ll long long #define maxn 100005 /*rem*/ #define mod 1000000007 #define db double #define vi vector #define pb push_back #define mp make_pair #define pi pair #define fi first #define se second template bool chkmax(T &x,T y){return x bool chkmin(T &x,T y){return x>y?x=y,true:false;} using namespace std; ll ksm(ll a, ll b) { if (!b) return 1; ll ns = ksm(a, b >> 1); ns = ns * ns % mod; if (b & 1) ns = ns * a % mod; return ns; } const int S = 1000005; bool bpr[S]; int miu[S]; int dv[S]; ll sum[S]; ll cal(ll C) { ll res = 0; for (ll i = 1; i <= C; ) { ll d = C / i; ll nx = (C / d) + 1; ll cm = (nx - i) % mod * ((nx - 1 + i) % mod) % mod * d % mod * (mod + 1) / 2 % mod; res = (res + cm) % mod; i = nx; } return res; } int main() { for (int i = 1; i < S; i++) bpr[i] = 1, miu[i] = 1; bpr[1] = 0; for (int j = 1; j < S; j++) { for (int k = j; k < S; k += j) dv[k] += j; if (bpr[j]) { for (int k = 1; k * j < S; k++) bpr[k * j] = 0, miu[k * j] *= -1; if (1ll * j * j < S) { for (int k = 1; k * j * j < S; k++) miu[k * j * j] = 0; } } } for (int j = 1; j < S; j++) sum[j] = sum[j - 1] + dv[j], sum[j] %= mod; /* for (int j = 1; j < S; j++) if ((cal(j) != sum[j])) cout << "WA" << j << endl; else cout << "COOL" << endl; */ int t = 0; cin >> t; while (t--) { ll n; scanf("%lld", &n); ll ans = 0; for (int r = 1; 1ll * r * r <= n; r++) { if (!miu[r]) continue; ll cur = miu[r] * r; ll e = n / r / r; ll res = 0; if (e < S) res = sum[e]; else res = cal(e); ans = (ans + cur * res) % mod; } ans %= mod; if (ans < 0) ans += mod; cout << ans << endl; } return 0; } /* 10 1000000000000 */