#include using namespace std; typedef long long ll; #define rep(i, m, n) for(ll i = m; i < n; ++i) const ll MAXN = 10000001; ll f[MAXN]; void Euler_Totient() { rep(i, 0, MAXN) f[i] = i; rep(i, 2, MAXN) if(f[i] == i) for(ll j = i; j <= MAXN - 1; j += i) f[j] = f[j] / i * (i - 1); } int main() { ios::sync_with_stdio(0); cin.tie(0); Euler_Totient(); rep(i, 1, MAXN) f[i] += f[i - 1]; ll T; cin >> T; while(T--) { ll N; cin >> N; cout << N * (N - 1) - f[N] + 1<< "\n"; } return 0; }