#include #define all(vec) vec.begin(), vec.end() #define pb push_back #define eb emplace_back using namespace std; using ll = long long; using P = pair; using V = vector; using VL = vector; constexpr ll INF = (1LL << 30) - 1LL; constexpr ll MOD = 1e9 + 7; constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; template void chmin(T &a, T b) { a = min(a, b); } template void chmax(T &a, T b) { a = max(a, b); } void ok() { cerr << "ok" << endl; } bool so[31][31]; int main() { cin.tie(0); ios::sync_with_stdio(0); int t; cin >> t; for (int i = 1; i <= 30; i++) { for (int j = 1; j <= 30; j++) { if (__gcd(i, j) == 1) { so[i][j] = 1; } } } while (t--) { ll n; cin >> n; ll res = n * n + n * (n - 1LL); for (ll k = 2; k <= 30; k++) { ll ok = 0, ng = n + 1; auto check = [&](ll x) { ll s = 1LL; for (int i = 0; i < k; i++) { s *= x; if (s > n) return false; } return true; }; while (ng - ok > 1LL) { ll mid = (ok + ng) / 2LL; if (check(mid)) { ok = mid; } else { ng = mid; } } ll dc = n / k; res += dc * (ok - 1LL) * 2LL; } for (ll k = 2; k <= 30; k++) { for (ll a = 2; a * a <= n; a++) { ll s = 1; bool f = true; if (k >= 3) { for (int i = 0; i < k; i++) { s *= a; if (s > n) f = false; } } if (!f) break; for (ll l = 2; l <= k; l++) { if (so[k][l]) { res += n / max(k, l); if (k > l) { res += n / max(k, l); } } } } } cout << res << '\n'; } }