#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
  string sep = " ";
  if (v.size()) os << v[0];
  for (int i = 1; i < v.size(); i++) os << sep << v[i];
  return os;
}
void solve() {
  long long n;
  cin >> n;
  int ans = 0;
  while (n >= 2) {
    long long lb = 1, ub = 1e8;
    while (ub - lb > 1) {
      long long x = (ub + lb) / 2;
      if (x * (3 * x + 1) / 2 <= n) {
        lb = x;
      } else {
        ub = x;
      }
    };
    n -= lb * (3 * lb + 1) / 2;
    ans++;
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) solve();
  return 0;
}
