#include<bits/stdc++.h> #define re register #define int long long #define Add(a,b) (((a) % mod + (b) % mod) % mod) #define Sub(a,b) ((((a) % mod - (b) % mod) % mod + mod) % mod)
usingnamespace std;
constint N = 1e6 + 10,mod = 1e9 + 7; int dp[N]; bool vis[N];
inlineintread(){ int r = 0,w = 1; char c = getchar(); while (c < '0' || c > '9'){ if (c == '-') w = -1; c = getchar(); } while (c >= '0' && c <= '9'){ r = (r << 3) + (r << 1) + (c ^ 48); c = getchar(); } return r * w; }
inlinevoidinit(){ for (re int i = 2;i <= 1e6;i++){ if (!vis[i] || i == 4){ for (re int j = i;j <= 1e6;j += i){ vis[j] = true; int val = j / i; if (i == 4) val *= 2; else val *= (i - 1); val %= i; dp[j] = Add(dp[j],val); if (i + j <= 1e6) dp[i + j] = Sub(dp[i + j],val); } } } for (re int i = 1;i <= 1e6;i++) dp[i] = Add(dp[i - 1],dp[i]); for (re int i = 1;i <= 1e6;i++) dp[i] = Add(dp[i - 1],dp[i]); }
signedmain(){ init(); int T; T = read(); while (T--) printf("%lld\n",dp[read()]); return0; }