#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<long long> values;
  for (long long i = 1; i < 1e5; i++) {
    long long num = i * (3 * i + 1) / 2;
    values.push_back(num);
  }
  long long t;
  cin >> t;
  while (t--) {
    long long n, rem, count = 0;
    cin >> n;
    rem = n;
    while (rem > 1) {
      long long index =
          lower_bound(values.begin(), values.end(), rem) - values.begin();
      if (values[index] == rem) {
        count++;
        break;
      }
      count++;
      rem = rem - values[index - 1];
    }
    cout << count << endl;
  }
}
