#include using namespace std; using ll = long long; const int INF = 1e9 + 10; const ll INFL = 4e18; vector totientTable(ll n) { vector ret(n + 1); iota(ret.begin(), ret.end(), 0); for (ll i = 2; i <= n; i++) { if (ret[i] == i) { for (ll j = i; j <= n; j += i) ret[j] = ret[j] / i * (i - 1); } } return ret; } /* 考察 dist(i,j)= 1(gcd(i,j)=1) 2(else) */ int main() { int T; cin >> T; const int mx = 1e7 + 5; auto tot = totientTable(mx); tot[1]--; vector pref(mx + 1); for (int i = 1; i < mx; i++) pref[i + 1] = pref[i] + tot[i] + (i - tot[i] - 1) * 2; while (T--) { int N; cin >> N; cout << pref[N + 1] << '\n'; } }