#include using namespace std; #define rep(i, n) for (int i=0; i 1) ret -= ret / n; return ret; } struct Fast_factorize { vector p; Fast_factorize(int n) { p.resize(n+1); fill(p.begin(), p.end(), -1); for (int i=2; i<=n; i++) if (p[i]==-1) { for (int j=i; j<=n; j+=i) { if (p[j]==-1) p[j] = i; } } } vector factorize(int n) { vector res; while (n>1) { res.pb(p[n]); n /= p[n]; } return res; } }; int main() { cin.tie(0); ios::sync_with_stdio(false); int MAX = 10000010; Fast_factorize ff(MAX); ll phi[MAX]; phi[0] = 0ll; for (int i=1; i ps = ff.factorize(i); sort(ps.begin(), ps.end()); ps.erase(unique(ps.begin(), ps.end()), ps.end()); int x = i; for (int p : ps) { phi[i] -= phi[i]/p; while (x%p==0) x /= p; } if (x>1) phi[i] -= phi[i]/x; } for (int i=1; i> T; while (T--) { int N; cin >> N; ll ans = (ll)(N)*(N-1); cout << ans-phi[N]+1 << endl; } }