#include <bits/stdc++.h>
using namespace std;
void solv() {
  long long int n;
  cin >> n;
  long long int ans = 0, curr;
  while (n > 1) {
    long long int x = 1;
    curr = (3 * x * x + x) / 2;
    while (curr <= n) {
      x++;
      curr = (3 * x * x + x) / 2;
    }
    x--;
    ans++;
    curr = (3 * x * x + x) / 2;
    n = n - curr;
  }
  cout << ans;
  return;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long int t;
  cin >> t;
  while (t--) {
    solv();
    cout << endl;
  }
  return 0;
}
