/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
ifstream fin("sum.in");
ofstream fout("sum.out");
int q,x;
int phi(int n)
{
int r=n,d=2,t=0;
if(n==1) return 1;
while(n>1&&d*d<=n)
{
if(n%d==0)
{
r=r/d*(d-1);
while(n%d==0) {n/=d;t++;}
}
d++;
}
if(n>1) r=r/n*(n-1);
return r;
}
int main()
{
fin>>q;
while(q)
{
fin>>x;
fout<<phi(x)*2*x<<'\n';
q--;
}
return 0;
}