#include <stdio.h>
#include <math.h>
#define INF 100000
char v[100000];
unsigned long n,x,i,j,nr,c,sq/*,p[10000]*/;
unsigned long long s,ttnt;
int p[]={0,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,
101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,
199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,
317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,
443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,
577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,
701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,
839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,
983,991,997,1001,1003,1005,1007,1009,1011,1013,1015,1017,1019,1021,1023,1025,1027,
1029,1031,1033,1035,1037,1039,1041,1043,1045,1047,1049,1051,1053,1055,1057,1059,
1061,1063,1065,1067,1069,1071,1073,1075,1077,1079,1081,1083,1085,1087,1089,1091,
1093,1095,1097,1099,1101,1103,1105,1107,1109,1111,1113,1115,1117,1119,1121,1123,
1125,1127,1129,1131,1133,1135,1137,1139,1141,1143,1145,1147,1149,1151,1153,1155,
1157,1159,1161,1163,1165,1167,1169,1171,1173,1175,1177,1179,1181,1183,1185,1187,
1189,1191,1193,1195,1197,1199,1201,1203,1205,1207,1209,1211,1213,1215,1217,1219,
1221,1223,1225,1227,1229,1231,1233,1235,1237,1239,1241,1243,1245,1247,1249,1251,
1253,1255,1257,1259,1261,1263};
int main()
{
freopen("sum.in","r",stdin);
freopen("sum.out","w",stdout);
/*c=1;
p[1]=2;
for(i=3;i<=INF;i=i+2)
if(!v[i]) {p[++c]=i;
for(j=3*i;j<=INF;j=j+2*i)v[j]=1;}*/
scanf("%ld\n",&n);
for(;n;n--)
{
scanf("%ld",&x);
j=1;
ttnt=x;nr=x;
while (nr>1){
if (nr%p[j]==0){
while(nr%p[j]==0)nr/=p[j];
ttnt=ttnt*(p[j]-1)/p[j];
}
j++;
}
s=2*ttnt*x;
printf("%lld\n",s);
ttnt=0;s=0;
}
return 0;
}