#include <bits/stdc++.h>
using namespace std;
const long long maxa = 2e9;
vector<long long> d;
void start() {
  long long t = 2;
  d.push_back(t);
  long long t2 = 1;
  while (t <= maxa) {
    t += t2 + (t2 + 1) * 2;
    t2++;
    d.push_back(t);
  }
}
int main() {
  long long t;
  cin >> t;
  start();
  while (t--) {
    long long n;
    cin >> n;
    long long res = 0;
    long long it = upper_bound(d.begin(), d.end(), n) - d.begin() - 1;
    for (; n > 1; it--) {
      while (d[it] <= n) {
        n -= d[it];
        res++;
      }
    }
    cout << res << endl;
  }
}
