#include <bits/stdc++.h>
using namespace std;
long long cost(long long h) { return (h - 1) * h / 2 * 3 + 2 * h; }
void solve() {
  long long n, ans = 0;
  cin >> n;
  while (1) {
    int lo = 0, hi = n / 2;
    while (lo < hi) {
      int mid = (lo + hi + 1) / 2;
      long long co = cost(mid);
      if (co > n) {
        hi = mid - 1;
      } else if (co == n) {
        cout << ans + 1 << endl;
        return;
      } else {
        lo = mid;
      }
    }
    if (lo == 0) break;
    if (lo == hi) {
      ans++;
      n -= cost(lo);
    }
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int T_ = 1;
  cin >> T_;
  for (int i = 0; i < T_; i++) solve();
  return 0;
}
