#include <bits/stdc++.h>
using namespace std;
long long t;
int32_t main() {
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long ans = 0;
    while (n > 1) {
      long long low = 0;
      long long upp = n;
      while (low != upp) {
        long long m = low + (upp - low) / 2;
        if (((m * (3 * m + 1)) / 2) <= n)
          low = m + 1;
        else if (((m * (3 * m + 1)) / 2) > n)
          upp = m;
      }
      low--;
      n -= ((low * (3 * low + 1)) / 2);
      ans++;
    }
    cout << ans << "\n";
  }
}
