t=int(input()) for _ in range(t):     x = int(input())     if x<4:         print(0)     else:         i=1         while x>=(i+1)*2*i:             i+=1         x -= i * 2 * (i - 1)         ans=(i-1)**2         while x>=3:             x-=3             ans+=1             if x>2*(i-1):                 x-=2*(i-1)                 ans+=i-1             else:                 ans+=x//2                 break             i+=1         print(ans)