# coding: utf-8 T=int(input()) for t in range(T): N=int(input()) ans=N*N+N*(N-1) for i in range(2,10): ans+=(N//i) * (int(N**(1/i))-1) * 2 print(ans)