#include #include #include #define N 200000 #define rg register #define mo 1000000007 using namespace std; const int oo=1<<30; const int M=(1<<19)-1; class map{public: int et,la[M+1]; struct E{int nxt,x,ans;}e[1<<19]; inline int find(rg int x){ for(rg int i=la[x&M];i;i=e[i].nxt) if(e[i].x==x)return e[i].ans; return -oo; } inline void ins(rg int x,rg int ans){ e[++et]=(E){la[x&M],x,ans},la[x&M]=et; } } ma; struct edge{bool fl;int id,next;} e[4544230]; int sumf[N+5],cnt,ljb[N+5],chu6,chu2; long long ksm(long long a,long long b){ long long ret=1; for (long long lj=a;b;b/=2,lj=lj*lj%mo) if (b&1) ret=ret*lj%mo; return ret; } int sg(int x){ return (1ll*x*(x+1ll)%mo*(x*2ll+1ll)%mo*chu6%mo-3ll*x%mo*(x+1ll)%mo*chu2%mo+2ll*x)%mo; } int sf(int n){ if (n<=N) return sumf[n]; rg int ans=ma.find(n); if(ans!=-oo)return ans;ans=sg(n); for(rg int l=2,r;l<=n;l=r+1)r=n/(n/l),ans=(ans-(0ll+r-l+1ll)*sf(n/l)%mo)%mo; return ma.ins(n,ans),ans; } int main(){ chu6=ksm(6,mo-2);chu2=ksm(2,mo-2); for (rg int i=1;i<=N;i++) sumf[i]=sg(i); for (rg int i=2;i<=N;i++){ for (rg int j=i;j<=N;j+=i){ e[++cnt].fl=0;e[cnt].id=j/i;e[cnt].next=ljb[j];ljb[j]=cnt; e[++cnt].fl=1;e[cnt].id=j/i;e[cnt].next=ljb[min(j+i-1,N)+1];ljb[min(j+i-1,N)+1]=cnt; } } int s=0; for (rg int i=2;i<=N;i++){ for (rg int j=ljb[i];j;j=e[j].next) if (!e[j].fl) s=(s-sumf[e[j].id])%mo; else s=(s+sumf[e[j].id])%mo; sumf[i]=(sumf[i]+s)%mo; } int tt;scanf("%d",&tt); for (;tt--;){ int n;scanf("%d",&n); printf("%d\n",(sf(n)+mo)%mo); } }