#include <bits/stdc++.h>
using namespace std;
const int maxn = 200009;
const long long MOD = 119 << 23 | 1;
class {
 public:
  vector<long long> a;
  void solve() {
    a.push_back(2);
    for (int i = 1;; ++i) {
      a.push_back(a.back() + i * 3 + 2);
      if (a.back() >= 1e9) break;
    }
    int t;
    cin >> t;
    while (t--) {
      int n;
      cin >> n;
      int ans = 0;
      for (int j = a.size() - 1; j >= 0; --j) {
        while (n >= a[j]) {
          n -= a[j];
          ans++;
        }
      }
      cout << ans << '\n';
    }
  }
} NSPACE;
int main() {
  ;
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  NSPACE.solve();
}
