#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define PB push_back
#define FI first
#define SE second
#define PI pair<int,int>
#define MP make_pair
#define Aint(DATAST) DATAST.begin(), DATAST.end()
#define MOD 1000000007
#define SIZE 10000001
int tot[SIZE];
int ans[SIZE];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
for (ll i = 0; i < SIZE; i++)
tot[i] = i;
for (ll i = 2; i < SIZE; i++)
{
if (tot[i] == i)
{
for (ll j = i; j < SIZE; j += i)
tot[j] -= tot[j] / i;
}
}
memset(ans, 0, sizeof(ans));
for (ll i = 1; i < SIZE; i++)
{
for (ll j = i; j < SIZE; j += i)
ans[j] += (tot[i] * i);
}
int t, n;
cin >> t;
while (t--)
{
cin >> n;
cout << ans[n] << endl;
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBsbCBsb25nIGxvbmcKI2RlZmluZSBQQiBwdXNoX2JhY2sKI2RlZmluZSBGSSBmaXJzdAojZGVmaW5lIFNFIHNlY29uZAojZGVmaW5lIFBJIHBhaXI8aW50LGludD4KI2RlZmluZSBNUCBtYWtlX3BhaXIKI2RlZmluZSBBaW50KERBVEFTVCkgREFUQVNULmJlZ2luKCksIERBVEFTVC5lbmQoKQojZGVmaW5lIE1PRCAxMDAwMDAwMDA3CiNkZWZpbmUgU0laRSAxMDAwMDAwMQoKaW50IHRvdFtTSVpFXTsKaW50IGFuc1tTSVpFXTsKCmludCBtYWluKCkKewogICAgaW9zOjpzeW5jX3dpdGhfc3RkaW8oMCk7CiAgICBjaW4udGllKDApOyBjb3V0LnRpZSgwKTsKI2lmbmRlZiBPTkxJTkVfSlVER0UKICAgIGZyZW9wZW4oImlucHV0LnR4dCIsICJyIiwgc3RkaW4pOwogICAgZnJlb3Blbigib3V0cHV0LnR4dCIsICJ3Iiwgc3Rkb3V0KTsKI2VuZGlmCgogICAgZm9yIChsbCBpID0gMDsgaSA8IFNJWkU7IGkrKykKICAgICAgICB0b3RbaV0gPSBpOwoKICAgIGZvciAobGwgaSA9IDI7IGkgPCBTSVpFOyBpKyspCiAgICB7CiAgICAgICAgaWYgKHRvdFtpXSA9PSBpKQogICAgICAgIHsKICAgICAgICAgICAgZm9yIChsbCBqID0gaTsgaiA8IFNJWkU7IGogKz0gaSkKICAgICAgICAgICAgICAgIHRvdFtqXSAtPSB0b3Rbal0gLyBpOwogICAgICAgIH0KICAgIH0KCiAgICBtZW1zZXQoYW5zLCAwLCBzaXplb2YoYW5zKSk7CgogICAgZm9yIChsbCBpID0gMTsgaSA8IFNJWkU7IGkrKykKICAgIHsKICAgICAgICBmb3IgKGxsIGogPSBpOyBqIDwgU0laRTsgaiArPSBpKQogICAgICAgICAgICBhbnNbal0gKz0gKHRvdFtpXSAqIGkpOwogICAgfQoKICAgIGludCB0LCBuOwogICAgY2luID4+IHQ7CgoKICAgIHdoaWxlICh0LS0pCiAgICB7CiAgICAgICAgY2luID4+IG47CiAgICAgICAgY291dCA8PCBhbnNbbl0gPDwgZW5kbDsKICAgIH0KCgogICAgcmV0dXJuIDA7Cn0=