#include <bits/stdc++.h>
using namespace std;
void solve();
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
    cout << "\n";
  }
  cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
  return 0;
}
void solve() {
  int a, f = 0;
  cin >> a;
  while (a > 0) {
    int t = 2;
    if (a == 1) f += 0;
    if (a == 2) f += 1;
    if (a > 2) {
      for (int i = 1;; i++) {
        if (a - t < 3 * i + 2) {
          f += 1;
          break;
        }
        t = t + 3 * i + 2;
      }
    }
    a = a - t;
  }
  cout << f << endl;
}
