#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
#define DIM 100005
vector <int> phi;
int N, x;
void totient() {
for(int i = 2; i < DIM; ++i) {
phi[i] = i - 1;
}
for(int i = 2; i < DIM; ++i) {
for(int j = i * 2; j < DIM; j += i) {
phi[j] -= phi[i];
}
}
}
int main() {
freopen("sum.in","r",stdin);
freopen("sum.out","w",stdout);
phi.resize(DIM + 1);
totient();
scanf("%d\n", &N);
while(N--) {
scanf("%d\n", &x);
cout << (long long)2 * (long long)phi[x] * (long long)x << '\n';
}
return 0;
}