t=int(input()) for i in range(t): n=int(input()) a=(n-1)/3 b=(n-1)/5 c=(n-1)/15 ans=(3*a*(a+1)/2)+(5*b*(b+1)/2)-(15*c*(c+1)/2) print(ans)