#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //#include #define rep(i,n) for(int i=0;i<(n);i++) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define sz(x) ((int)(x).size()) #define pb push_back using ll = long long; using namespace std; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b 1) ret -= ret / n; return ret; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int e7 = 10000000; vector prime(e7+1, 0); prime[0] = prime[1] = 1; for(int i=2; i <= e7; i++){ if(prime[i]==0){ for(int j=i*2; j <= e7; j+=i){ if(prime[j]==0) prime[j]=i; } prime[i]=i; } } vector ps(e7+2,0); for(int i=2;i<=e7;i++){ int now = i; ll ret = now; while(now!=1){ int d = prime[now]; ret -= ret / d; while(now%d==0) now/=d; } if(now>1) ret -= ret/now; ps[i+1] = ps[i]+ret; } int T; cin >> T; while(T--){ ll N; cin >> N; ll ans = N*(N-1); ans -= ps[N+1]; cout << ans << '\n'; } return 0; }