#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; const ll sz=1e7; ll phi[sz+1], S[sz+1]; void init(){ phi[0] = 0; for (int i=2; i<=sz; i++) phi[i] = i; for (int i=2; i<=sz; i++){ if (phi[i] == i){ for (int j=i; j<=sz; j+=i){ phi[j] /= i; phi[j] *= (i-1); } } } S[0] = 0; for (int i=1; i<=sz; i++){ S[i] = S[i-1] + phi[i]; } } int main(){ init(); ll T, N, M, K; cin >> T; while(T){ T--; cin >> N; M = N*(N-1)/2; K = S[N]; cout << K + (M-K)*2 << endl; } return 0; }