#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  vector<long long> a(100001);
  for (long long i = 0; i <= 100000; i++) a[i] = (i * (3 * i + 1)) / 2;
  while (t--) {
    long long n;
    cin >> n;
    long long ans = 0;
    while (n > 1) {
      long long k = lower_bound(a.begin(), a.end(), n) - a.begin();
      if (a[k] == n) {
        ans++;
        break;
      } else
        k--;
      if (k < 0) break;
      n = n - a[k];
      ans++;
    }
    cout << ans << '\n';
  }
  return 0;
}
