#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long cnt = 0;
    while (n > 1) {
      long long h = 0;
      long long minm = 0, maxm = n;
      while (minm <= maxm) {
        long long mid = minm + (maxm - minm) / 2;
        if ((mid - 1) * (3 * mid + 4) <= (n - 2) * 2) {
          h = mid;
          minm = mid + 1;
        } else {
          maxm = mid - 1;
        }
      }
      if (h != 0) {
        long long c = 2 + ((h - 1) * (3 * h + 4) / 2);
        cnt++;
        n = n - c;
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
