#include using namespace std; template void read(T &t) { t=0; char ch=getchar(); int f=1; while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); } do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f; } typedef long long ll; const ll mod=(1e9)+7; const int maxn=1000010; int T,mx; ll ans,n,tmp,f[maxn],l,r; ll c(ll x) { if (x%2==0) return ((x/2)%mod)*((x+1)%mod)%mod; return (((x+1)/2)%mod)*(x%mod)%mod; } void update(ll &x,ll y) { x+=y%mod; if (x>=mod) x-=mod; } int main() { //freopen("1.txt","r",stdin); read(T); while (T--) { read(n); ans=0; mx=0; for (ll d=1;d*d<=n;d++) { tmp=n/d/d; f[d]=0; mx=d; for (ll x=1;x*x<=tmp;x++) { update(f[d],x); if (x*x==tmp) break; else { l=x+1,r=tmp/x; update(f[d],(ll)x%mod*((r-l+1)%mod)%mod); update(f[d],(c(r)-c(l-1)+mod)%mod); } } f[d]=f[d]*d%mod; //printf("%lld %lld\n",d,f[d]); } for (int i=mx;i>=1;i--) for (int j=i+i;j<=mx;j+=i) update(f[i],mod-f[j]); printf("%lld\n",f[1]); } return 0; } /* 0. Enough array size? Enough array size? Enough array size? Interger overflow? 1. Think TWICE, Code ONCE! Are there any counterexamples to your algo? 2. Be careful about the BOUNDARIES! N=1? P=1? Something about 0? 3. Do not make STUPID MISTAKES! Time complexity? Memory usage? Precision error? */