#include using namespace std; #ifdef _RUTHEN #include #else #define show(...) true #endif using ll = long long; #define rep(i, n) for (int i = 0; i < (n); i++) template using V = vector; std::vector totient_table(int n) { std::vector res(n + 1); std::iota(res.begin(), res.end(), 0); for (int p = 2; p <= n; p++) { if (res[p] != p) continue; for (int i = p; i <= n; i += p) { res[i] /= p; res[i] *= p - 1; } } return res; } template struct CumulativeSum { int n; std::vector seg; CumulativeSum() = default; CumulativeSum(int n) : n(n), seg(n + 1, T(0)) {} CumulativeSum(std::vector &a) { n = (int)a.size(); seg.assign(n + 1, T(0)); for (int i = 0; i < n; i++) seg[i + 1] = seg[i] + a[i]; } // [l, r) T sum(int l, int r) const { assert(0 <= l and l <= r and r <= n); return seg[r] - seg[l]; } // A[l] += x, A[l + 1] += x, ... , A[r - 1] += x void imos(int l, int r, T x = T(1)) { assert(0 <= l and l <= r and r <= n); seg[l] += x; seg[r] -= x; } void build() { for (int i = 0; i < n; i++) seg[i + 1] += seg[i]; } // return A[p] T get(int p) const { assert(0 <= p and p < n); return seg[p]; } // output friend std::ostream &operator<<(std::ostream &os, const CumulativeSum &A) { os << "n = " << A.n << "\n"; for (int i = 0; i <= A.n; i++) os << A.seg[i] << " \n"[i == A.n]; return os; } }; int main() { ios::sync_with_stdio(false); cin.tie(0); auto ttt = totient_table(10000000); V tl(10000001); rep(i, 10000001) tl[i] = ttt[i]; CumulativeSum seg(tl); int tt; cin >> tt; while (tt--) { long long N; cin >> N; long long ans = N * (N - 1) - seg.sum(0, N + 1) + 1; cout << ans << '\n'; } return 0; }