from math import gcd def root(n,k): for i in range(n+9): if i**k > n: return i-2 t,*a = map(int,open(0).read().split()) for n in a: R = [0,0]+[root(n,k) for k in range(2,30)] ans = 2*n*n-n for i in range(1,30): for j in range(i+1,30): if gcd(i,j) > 1: continue ans += n//j*R[j]*2 print(ans)