#include #include #include #include #include #define ALL(V) std::begin(V), std::end(V) const int SIZE = 1e7 + 10; using ll = long long; std::vector> p_divs(SIZE); int calc_non_disj(int num, int idx, int acc) { if (idx == p_divs[num].size()) return (acc == 1 ? 0 : (num - 1) / acc); return calc_non_disj(num, idx + 1, acc) - calc_non_disj(num, idx + 1, acc * p_divs[num][idx]); } int main() { std::vector primes; { std::vector flags(SIZE); for (int i = 2; i < SIZE; i++) { if (flags[i]) continue; primes.push_back(i); for (int j = i; j < SIZE; j += i) flags[j] = true; } } for (auto p : primes) { for (int i = p; i < SIZE; i += p) { p_divs[i].push_back(p); } } std::vector non_disj(SIZE); for (int i = 1; i < SIZE; i++) { non_disj[i] = -calc_non_disj(i, 0, 1); } std::vector sum(SIZE + 1); for (int i = 0; i < SIZE; i++) sum[i + 1] = sum[i] + non_disj[i]; std::ios::sync_with_stdio(false); int T; std::cin >> T; while (T--) { ll N; std::cin >> N; ll ans = N * (N - 1) / 2; ans += sum[N + 1]; std::cout << ans << '\n'; } return 0; }