#include #define LL long long using namespace std; const int M = 1000005,P = 1e9 + 7; int p[78498+50],mu[M],cntp; bool vis[M]; inline void sieve(int n){ int i,j; mu[1] = 1,cntp = 0; for (i = 2; i <= n; ++i){ if (!vis[i]) p[++cntp] = i,mu[i] = -1; for (j = 1; j <= cntp && i * p[j] <= n; ++j){ vis[i*p[j]] = 1; if (i%p[j]) mu[i*p[j]] = -mu[i]; else{ mu[i*p[j]] = 0; break; } } } for (i = 1; i <= n; ++i) mu[i] = (mu[i]%P+P)%P; for (i = 1; i <= n; ++i) mu[i] = 1ll*mu[i]*i%P; for (i = 1; i <= n; ++i) mu[i] += mu[i-1],mu[i] %= P; for (i = 1; i <= n; ++i) mu[i] = (mu[i]%P+P)%P; } inline int calc(LL l,LL r){ static LL a,b; a = (r-l+1),b = (l+r); if (a&1) b>>=1; else a>>=1; return a%P*(b%P)%P; } mapGG; inline int G(LL n){ if (GG.count(n)) return GG[n]; LL sum = 0,l = 1,r,v; while (l <= n) v = n/l,r = n/v,sum = (sum + 1ll * calc(l,r) % P * (v%P)) % P,l = r+1; return GG[n] = sum; } int main(){ sieve(1000000); int T; cin >> T; while (T--){ LL n,l,r,v,ans = 0; cin >> n; l = 1; while (l <= n / l){ v = n / l / l,r = sqrt(n/v); ans =(ans + (mu[r]-mu[l-1]+P) % P * 1ll * G(v) % P) %P; l = r+1; } cout << ans << '\n'; } return 0; }