#include #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--) #define all(x) (x).begin(), (x).end() #define sz(x) int(x.size()) using namespace std; using ll = long long; constexpr int INF = 1e9; constexpr ll LINF = 1e18; string YesNo(bool cond) { return cond ? "Yes" : "No"; } string YESNO(bool cond) { return cond ? "YES" : "NO"; } template bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; } template bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } return false; } template T bisect(T ok, T ng, const F& f) { while (abs(ok - ng) > 1) { T mid = min(ok, ng) + (abs(ok - ng) >> 1); (f(mid) ? ok : ng) = mid; } return ok; } template T bisect_double(T ok, T ng, const F& f, int iter = 100) { while (iter--) { T mid = (ok + ng) / 2; (f(mid) ? ok : ng) = mid; } return ok; } template vector make_vec(size_t a) { return vector(a); } template auto make_vec(size_t a, Ts... ts) { return vector(ts...))>(a, make_vec(ts...)); } template istream& operator>>(istream& is, vector& v) { for (int i = 0; i < int(v.size()); i++) { is >> v[i]; } return is; } template ostream& operator<<(ostream& os, const vector& v) { for (int i = 0; i < int(v.size()); i++) { os << v[i]; if (i < sz(v) - 1) os << ' '; } return os; } #include int main() { const int MAX_N = 10000000; vector phi(MAX_N + 1); iota(all(phi), 0); for (int p = 2; p <= MAX_N; p++) { if (!atcoder::internal::is_prime_constexpr(p)) continue; for (int q = p; q <= MAX_N; q += p) { phi[q] /= p; phi[q] *= (p - 1); } } vector phi_sum(MAX_N + 1); rep(i, MAX_N) phi_sum[i + 1] += ll(phi[i + 1]) + phi_sum[i]; int tt; cin >> tt; while (tt--) { ll n; cin >> n; ll ans = n * (n - 1) - phi_sum[n] + 1; cout << ans << '\n'; } }