#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define LOG(FMT...) fprintf(stderr, FMT) using namespace std; typedef long long ll; typedef unsigned long long ull; // mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); template istream &operator>>(istream &is, vector &v) { for (T &x : v) is >> x; return is; } template ostream &operator<<(ostream &os, const vector &v) { if (!v.empty()) { os << v.front(); for (int i = 1; i < v.size(); ++i) os << ' ' << v[i]; } return os; } const int P = 1000000007; int norm(int x) { return x >= P ? (x - P) : x; } void add(int& x, int y) { if ((x += y) >= P) x -= P; } void sub(int& x, int y) { if ((x -= y) < 0) x += P; } void exGcd(int a, int b, int& x, int& y) { if (!b) { x = 1; y = 0; return; } exGcd(b, a % b, y, x); y -= a / b * x; } int inv(int a) { int x, y; exGcd(a, P, x, y); return norm(x + P); } int s1(int n) { return n * (n + 1LL) / 2 % P; } int main() { #ifdef ELEGIA freopen("test.in", "r", stdin); int nol_cl = clock(); #endif ios::sync_with_stdio(false); cin.tie(nullptr); const int L = 1000001; vector mu(L); mu[1] = 1; for (int i = 1; i < L; ++i) for (int j = i + i; j < L; j += i) mu[j] -= mu[i]; map mp; function solve = [&](ll x) { if (mp.count(x)) return mp[x]; int ret = 0; for (ll l = 1, r; l <= x; l = r + 1) { ll d = x / l; r = x / d; ret = (ret + (P + s1(r % P) - s1((l - 1) % P)) * (ll)(d % P)) % P; } return mp[x] = ret; }; int t; cin >> t; while (t--) { ll n; cin >> n; int ans = 0; for (int r = 1; r * (ll)r <= n; ++r) { int res = solve(n / r / r); if (mu[r] == 1) ans = (ans + res * (ll)r) % P; else if (mu[r] == -1) ans = (ans + res * (ll)(P - r)) % P; } cout << ans << '\n'; } #ifdef ELEGIA LOG("Time: %dms\n", int ((clock() -nol_cl) / (double)CLOCKS_PER_SEC * 1000)); #endif return 0; }