#include <bits/stdc++.h>
using namespace std;
const long long SZ = 1e5 + 7;
const long long inf = 1e18;
const long long mod = 1e9 + 7;
const long long MOD = 998244353;
vector<long long> pre(SZ);
void init() {
  for (long long i = 1; i < SZ; ++i) {
    pre[i] = pre[i - 1] + 3 * i - 1;
  }
}
void solve() {
  long long n;
  cin >> n;
  long long cnt = 0;
  while (n > 1) {
    long long l = 0;
    long long r = SZ;
    while (l + 1 < r) {
      long long mid = l + (r - l) / 2;
      if (pre[mid] > n) {
        r = mid;
      } else {
        l = mid;
      }
    }
    n -= pre[l];
    cnt++;
  }
  cout << cnt << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  init();
  long long t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
