#include <bits/stdc++.h>
using namespace std;
bool comp(pair<int, int> a, pair<int, int> b) {
  if (a.first > b.first) return true;
  return false;
}
int main() {
  int t;
  vector<long> ans;
  for (long i = 0; i * i <= 1e9; i++) {
    ans.push_back(3 * ((i * (i + 1)) / 2) - i);
  }
  cin >> t;
  while (t--) {
    long n;
    cin >> n;
    int ot = 0;
    int st = 0;
    int en = ans.size();
    int ct = 0;
    while (n > 1) {
      en = ans.size();
      st = 0;
      while (st <= en) {
        int mid = st + (en - st) / 2;
        if (ans[mid] > n) {
          en = mid - 1;
        } else {
          ot = mid;
          st = mid + 1;
        }
      }
      ct++;
      n -= ans[ot];
    }
    cout << ct << "\n";
  }
  return 0;
}
