#include<bits/stdc++.h>
using namespace std;
#define il inline void
#define ll long long
#define N 5000000
#define ull unsigned ll
#define minn(a,b) (a<b?a:b)
#define __int128 ll
struct ios {
inline char read(){
static const int IN_LEN=1<<18|1;
static char buf[IN_LEN],*s,*t;
return (s==t)&&(t=(s=buf)+fread(buf,1,IN_LEN,stdin)),s==t?-1:*s++;
}
template <typename _Tp> inline ios & operator >> (_Tp&x){
static char c11,boo;
for(c11=read(),boo=0;!isdigit(c11);c11=read()){
if(c11==-1)return *this;
boo|=c11=='-';
}
for(x=0;isdigit(c11);c11=read())x=x*10+(c11^'0');
boo&&(x=-x);
return *this;
}
}io;
template<class T>il _print(T x){
if(x/10) _print(x/10);
putchar(x%10+'0');
}
template<class T>il print(T x){
if(x<0) putchar('-'),x=-x;
_print(x);
}
__int128 phi[N+5];
ll primes[N],cnt_p;
bool st[N];
unordered_map<ull,__int128> ans_phi;
void init()
{
int n=N;
phi[1]=1;
for(int i=2;i<=n;i++)
{
if(!st[i])
primes[cnt_p++]=i,phi[i]=i-1;
for(int j=0;j<cnt_p&&primes[j]*i<=n;j++)
{
st[primes[j]*i]=1;
if(i%primes[j]==0)
{
phi[i*primes[j]]=primes[j]*phi[i];
break;
}
phi[i*primes[j]]=phi[primes[j]]*phi[i];
}
}
for(int i=1;i<=n;i++)
phi[i]+=phi[i-1];
}
__int128 sum(ll a)
{
__int128 temp=a*(a+1);
return temp/2;
}
__int128 get_phi(ll n)
{
if(n<=N)
return phi[n];
if(ans_phi[n])
return ans_phi[n];
__int128 res=sum(n);
for(__int128 l=2,r;l<=n;l=r+1)
{
r=minn(n,n/(n/l));
res-=1ll*(r-l+1)*get_phi(n/l);
}
return ans_phi[n]=res;
}
int main()
{
int T;
scanf("%d",&T);
init();
while(T--)
{
ll x;
scanf("%lld",&x);
unsigned ll ans=0;
for(__int128 l=1,r;l<=x;l=r+1)
{
r=x/(x/l);
ans+=(get_phi(x/l)-1)*(sum(r)-sum(l-1));
}
print(ans);
puts("");
}
return 0;
}