#include <bits/stdc++.h>
using namespace std;
void set_(vector<long long int> &v) {
  v.push_back(2);
  long long int i = 2;
  long long int cur = 2;
  while (cur <= 1e9) {
    cur = cur + 2 * i + i - 1;
    i++;
    v.push_back(cur);
  }
}
int main() {
  int t;
  cin >> t;
  vector<long long int> v;
  set_(v);
  while (t--) {
    long long int n;
    cin >> n;
    long long int res = 0;
    while (1) {
      if (n < 2) break;
      int i = 0;
      for (i = 0; i < v.size(); i++) {
        if (v[i] > n) break;
      }
      res++;
      n = n - v[i - 1];
    }
    cout << res << endl;
  }
  return 0;
}
