#include <bits/stdc++.h>
using namespace std;
long long int M = 1e9 + 7;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  vector<long long int> v;
  for (long long int i = 1; i <= 100000; ++i) {
    long long int x = (i * (3 * i + 1)) / 2;
    if (x <= 2e9) {
      v.push_back(x);
    }
  }
  while (t--) {
    long long int n;
    cin >> n;
    long long int ans = 0;
    while (n >= 2) {
      long long int x = lower_bound(v.begin(), v.end(), n) - v.begin();
      if (v[x] != n) x--;
      n -= v[x];
      ans++;
    }
    cout << ans << '\n';
  }
}
