#include<bits/stdc++.h>
using namespace std;
#define N 10000005
int f[N],prime[N],n,T;
bool vis[N];
void work(){
vis[0]=vis[1]=1;f[1]=1;
for(int i=2;i<=N;i++){
if(!vis[i])prime[++prime[0]]=i,f[i]=i-2;
for(int j=1;j<=prime[0]&&i*prime[j]<N;j++){
vis[i*prime[j]]=1;
if(i%prime[j]==0){
f[i*prime[j]]=prime[j]*f[i];
}else f[i*prime[j]]=f[prime[j]]*f[i];
}
}
}
int main(){
scanf("%d",&T);
work();
while(T--){
scanf("%d",&n);
printf("%d
",f[n]);
}
return 0;
}