#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int result = 0;
    int k;
    while (n >= 2) {
      k = (int)((-1.0 + sqrt(1 + (double)24 * n)) / 6.0);
      n -= (k * (3 * k + 1)) / 2;
      result++;
    }
    cout << result << endl;
  }
  return 0;
}
