#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << '\n';
  err(++it, args...);
}
void solve() {
  long long n;
  cin >> n;
  if (n < 2) {
    cout << 0 << '\n';
    return;
  }
  int ans = 0;
  while (n > 1) {
    int h = 0;
    for (int i = 1; i < 100000; ++i) {
      long long t = i * (3 * i + 1) / 2;
      if (t == n && ans == 0) {
        cout << 1 << '\n';
        return;
      } else if (t == n && ans > 0) {
        h = i;
        break;
      }
      if (t > n) {
        h = i - 1;
        break;
      }
    }
    n -= (h * (3 * h + 1) / 2);
    ++ans;
  }
  cout << ans << '\n';
}
int main() {
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
