#include <bits/stdc++.h>
using namespace std;
const int mxn = 100000;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, t;
  cin >> t;
  long long d[mxn];
  for (long long i = 1; i < mxn; i++) d[i] = (3 * i * i + i) / 2;
  while (t--) {
    cin >> n;
    int ans = 0;
    while (n >= 2) {
      auto it = lower_bound(d, d + mxn, n);
      if (*it != n) it--;
      n -= *it;
      ans++;
    }
    cout << ans << '\n';
  }
}
