#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long mod_pow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n) {
    if (n & 1) res = (res * a) % mod;
    n /= 2;
    a = (a * a) % mod;
  }
  return res;
}
void solve();
void init();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  init();
  int t;
  cin >> t;
  while (t--) solve();
}
const int maxn = 1e5;
vector<long long> lev(maxn);
void init() {
  lev[0] = 0;
  for (int i = 1; i < maxn; ++i) {
    lev[i] = lev[i - 1] + 3 * (i - 1) + 2;
  }
}
void solve() {
  long long n;
  cin >> n;
  int cnt = 0;
  while (n > 1) {
    long long ind = (lower_bound(lev.begin(), lev.end(), n) - lev.begin());
    if (lev[ind] > n) --ind;
    n -= lev[ind];
    cnt++;
  }
  cout << cnt << "\n";
}
