#include <bits/stdc++.h>
using namespace std;
long long int sub2(long long int n) { return (n + 3 * n * n) / 2; }
int main() {
  long long int t;
  cin >> t;
  vector<long long int> ans;
  while (t--) {
    long long int k;
    cin >> k;
    long long int m = 0;
    while (k >= 2) {
      long long int i = floor((sqrt(1 + 24 * k) - 1) / 6.0);
      k = k - sub2(i);
      m++;
    }
    ans.push_back(m);
  }
  for (long long int k = 0; k < ans.size(); k++) cout << ans[k] << endl;
  return 0;
}
