#include <bits/stdc++.h>
using namespace std;
long long bin(vector<long long> &vec, long long t) {
  long long l = 0, r = vec.size();
  while (r - l > 1) {
    long long m = l + (r - l) / 2;
    if (vec[m] > t) {
      r = m;
    } else {
      l = m;
    }
  }
  return vec[l];
}
int main() {
  int q;
  cin >> q;
  vector<long long> vec((long long)1e5, 0);
  vec[0] = 0;
  vec[1] = 2;
  for (int i = 2; i < (long long)1e5; i++) {
    vec[i] = (i * 3 - 1) + vec[i - 1];
  }
  long long a;
  for (int i = 0; i < q; i++) {
    cin >> a;
    long long ans = 0;
    long long tmp = bin(vec, a);
    while (tmp != 0) {
      a -= tmp;
      tmp = bin(vec, a);
      ans++;
    }
    cout << ans << "\n";
  }
  return 0;
}
