#include <bits/stdc++.h>
using namespace std;
struct hash_pair {
  template <class T1, class T2>
  size_t operator()(const pair<T1, T2>& p) const {
    auto hash1 = hash<T1>{}(p.first);
    auto hash2 = hash<T2>{}(p.second);
    return hash1 ^ hash2;
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    long double n;
    cin >> n;
    long long p = 0;
    while (n > 1) {
      long double h = 1 + (24 * n);
      h = sqrt(h);
      h -= 1;
      h /= 6;
      long long H = h;
      long long N = (((3 * H) + 1) * H) / 2;
      n -= N;
      p++;
    }
    cout << p << '\n';
  }
  return 0;
}
