#include using namespace std; const int MX = 1E7 + 5; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); vector pr(MX), phi(MX); phi[1] = 1; vector ans(MX); for (int i = 2; i < MX; i++) { if (pr[i] == 0) { pr[i] = i; for (int j = i; j <= (MX - 1) / i; j++) { pr[i * j] = i; } } int t = i, p = pr[i]; while (t % p == 0) { t /= p; } phi[i] = phi[t] * (i / t) / p * (p - 1); ans[i] = ans[i - 1] + phi[i] + (i - 1 - phi[i]) * 2; } int t; cin >> t; while (t--) { int u; cin >> u; cout << ans[u] << '\n'; } }