#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  long long int n;
  long long int root, temp, ans = 0, temp2;
  cin >> t;
  while (t != 0) {
    cin >> n;
    while (n > 1) {
      root = sqrt(n);
      temp = (long long int)(pow(root, 2) + 0.5);
      temp2 = (3 * temp + root) / 2;
      while (temp2 > n) {
        root--;
        temp = (long long int)(pow(root, 2) + 0.5);
        temp2 = (3 * temp + root) / 2;
      }
      n -= temp2;
      ans++;
    }
    cout << ans << '\n';
    ans = 0;
    t--;
  }
}
