#include <bits/stdc++.h>
using namespace std;
void pre() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int32_t main() {
  pre();
  vector<long long int> v;
  long long int s = 0, vl = 2, bs = 0, badd = 1;
  while (s <= 1e9 + 100000) {
    s += vl;
    v.push_back(s + bs);
    bs += badd;
    badd++;
    vl += 2;
  }
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    long long int ans = 0;
    while (1) {
      if (n < 2) {
        break;
      }
      for (long long int i = 0; i < v.size(); i++) {
        if (v[i] > n) {
          n -= v[i - 1];
          ans++;
          break;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
