#include using namespace std; const int mod = 1000000007; inline int qp(int a, int b) { int res = 1; while (b) { if (b & 1) res = 1ll * res * a % mod; a = 1ll * a * a % mod; b >>= 1; } return res; } const int N = 2000005; int zhi[N], pri[N], mu[N], tot; inline void Init(int n) { tot = 0; zhi[1] = mu[1] = 1; for (int i = 2; i <= n; i++) { if (!zhi[i]) { pri[++tot] = i; mu[i] = -1; } for (int j = 1; j <= tot && i * pri[j] <= n; j++) { zhi[i * pri[j]] = 1; if (i % pri[j] != 0) { mu[i * pri[j]] = -mu[i]; } else { mu[i * pri[j]] = 0; break; } } } } unordered_map mp; inline int gao(long long r) { long long tr = r + 1; if (tr & 1) r /= 2; else tr /= 2; return (r % mod) * (tr % mod) % mod; } inline int calc(long long n) { if (mp.find(n) != mp.end()) return mp[n]; int res = 0; for (long long l = 1, r; l <= n; l = r + 1) { r = n / (n / l); res = (res + (n / l) % mod * (gao(r) - gao(l - 1) + mod)) % mod; } return mp[n] = res; } int main() { int T; scanf("%d", &T); Init(2000000); while (T--) { long long n; scanf("%lld", &n); int ans = 0; for (long long d = 1; d * d <= n; d++) if (mu[d]) { int fuck = calc(n / d / d); if (mu[d] < 0) fuck = mod - fuck; ans = (ans + 1ll * fuck * d) % mod; if (ans < 0) ans += mod; } printf("%d\n", ans); } return 0; }