#include <bits/stdc++.h>
using namespace std;
int t, cnt;
long long ttl, l;
double p, n;
int main() {
  cin >> t;
  while (t--) {
    cin >> ttl;
    cnt = 0;
    while (1) {
      p = (double)ttl;
      n = (sqrt(1 + (24 * p)) - 1) / 6;
      l = (long long)n;
      if (l == 0) break;
      cnt++;
      ttl -= ((l * (3 * l + 1)) / 2);
    }
    cout << cnt << endl;
  }
}
