#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define oo 1000000000
#define PII pair <int, int>
using namespace std;
int n, tab[200100], x;
int main(){
cin.tie(0); cout.tie(0);
freopen("sum.in","r",stdin);
freopen("sum.out","w",stdout);
scanf("%d", &n);
for (int i = 1; i <= 100000; i++) tab[i] = i - 1;
for (int i = 2; i <= 100000; i++)
for (int j = i + i; j <= 100000; j += i)
tab[j] -= tab[i];
while (n--){
scanf("%d", &x);
ll rs = 2LL * x * tab[x];
printf("%lld\n", rs);
}
}