//pypyの遅さをなめるなよ() #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define rep(i,n) for (int i=0;i using vec = vector; template using vvec = vec>; template using vvvec = vec>; using ll = long long; using pii = pair; using pll = pair; template bool chmin(T &a, T b){ if (a>b){ a = b; return true; } return false; } template bool chmax(T &a, T b){ if (a T sum(vec x){ T res=0; for (auto e:x){ res += e; } return res; } template void printv(vec x){ for (auto e:x){ cout< ostream& operator<<(ostream& os, const vec& A){ os << "["; rep(i,A.size()){ os << A[i]; if (i!=A.size()-1){ os << ", "; } } os << "]" ; return os; } template ostream& operator<<(ostream& os, const deque& A){ os << "deque{["; rep(i,A.size()){ os << A[i]; if (i!=A.size()-1){ os << ", "; } } os << "]}" ; return os; } template ostream& operator<<(ostream& os, const pair& A){ os << "("; os << A.first ; os << ", "; os << A.second; os << ")"; return os; } const ll M = 10000000; ll mebius[M+1],phi[M+1]; void calc(){ mebius[0] = 0; for (ll n=0;n<=M;n++){ mebius[n] = 1ll, phi[n] = (ll)n; } for (ll p=2;p<=M;p++){ if (phi[p]==p){ for (ll k=p;k<=M;k+=p){ mebius[k] *= -1ll; if (k%(p*p) == 0ll){ mebius[k] = 0ll; } } } if (mebius[p]!=0ll){ for (ll k=p;k<=M;k+=p){ phi[k] += mebius[p] * (ll)(k/p); } } } for (int n=1;n<=M;n++){ phi[n] += phi[n-1]; } } int main() { ios::sync_with_stdio(false); std::cin.tie(nullptr); calc(); int T; cin>>T; while (T--){ ll N; cin>>N; ll res = N*(N-1) - (phi[N]-1); cout << res << endl; } }