#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int t, k;
  cin >> t;
  vector<long long> v(26000);
  for (int i = 1; i < 26000; i++) {
    v[i] = ((3 * i * i) + i) / 2;
  }
  while (t--) {
    long long n, ans = 0;
    cin >> n;
    k = upper_bound(v.begin(), v.end(), n) - v.begin() - 1;
    while (n > 1) {
      n -= v[k];
      k = upper_bound(v.begin(), v.end(), n) - v.begin() - 1;
      ans++;
    }
    cout << ans << endl;
  }
}
