#include <fstream>
#include <numeric>
using namespace std;
ifstream in ( "sum.in" );
ofstream out( "sum.out" );
const int DIM = 1e5 + 5;
int phi[DIM];
int main( int argc, const char *argv[] ) {
ios::sync_with_stdio( false );
iota( phi + 1, phi + DIM, 1 );
for( int i = 2; i < DIM; i ++ ) {
if( phi[i] != i ) {
continue; }
for( int j = i; j < DIM; j += i ) {
phi[j] = ( phi[j] / i ) * (i - 1); } }
int n; in >> n;
for( int i = 1; i <= n; i ++ ) {
int x; in >> x;
out << 2LL * x * phi[x] << "\n"; }
return 0; }