#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, n, ans;
  cin >> t;
  while (t--) {
    cin >> n;
    ans = 0;
    while (n > 1) {
      long long h = (long)((-1 + sqrt(24 * n + 1)) / 6);
      n -= (h * (3 * h + 1)) / 2;
      ans++;
    }
    cout << ans << endl;
  }
}
