#include #include #include #include #include #include #include #include #include #include #include using namespace std; #define MOD 1000000007 #define MOD2 998244353 #define INF ((1<<30)-1) #define LINF (1LL<<60) #define EPS (1e-10) typedef long long Int; typedef pair P; Int gcd(int x, int y){ if(x == 0)return y; return gcd(y % x, x); } int totient(int x){ Int ans = 0; for(int i = 1;i <= x;i++){ ans += gcd(i, x) == 1; } return ans; } Int larger(Int a, Int b,Int x){ Int tmp = 1; for(int i = 5;i >= 0;i--){ tmp *= tmp; if(tmp >= x)return true; if((b & (1 << i)) == 0)continue; tmp *= a; if(tmp >= x)return true; } return false; } void solve(){ Int n; cin >> n; Int ans = n*n * 2 - n; for(Int q = 2;q < 40;q++){ Int bottom = 0, top = n; while(top - bottom > 1){ Int mid = (top + bottom) / 2; if(larger(mid, q, n))top = mid; else bottom = mid; } if(bottom == 1)break; ans += (n / q) * totient(q) * (bottom -1)* 2; } cout << ans << endl; } int main(){ int t; cin >> t; while(t--)solve(); return 0; }