#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
long long w[N];
long long cnt[N] = {0};
string s;
long long get(long long x) {
  if (x != w[x]) w[x] = get(w[x]);
  return w[x];
}
void merge(long long a, long long b) {
  a = get(a);
  b = get(b);
  w[a] = b;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  vector<long long> v;
  long long t, i;
  cin >> t;
  for (i = 0; i < 500000; i++) {
    long long x = (i * (3 * i + 1)) / 2;
    v.push_back(x);
  }
  while (t--) {
    long long n;
    cin >> n;
    long long cnt = 0;
    while (n > 1) {
      long long x = upper_bound(v.begin(), v.end(), n) - v.begin();
      n = n - v[x - 1];
      cnt++;
    }
    cout << cnt << endl;
  }
}
