#include <bits/stdc++.h>
using namespace std;
int typetest;
inline void fastIOfileinput() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  typetest = 1;
}
const int N = 1e2 + 2;
long long n;
void Enter() { cin >> n; }
long long cnt() {
  return (long long)((long long)sqrt((long double)(24 * n + 1)) - 7) / 6;
}
void solve() {
  long long ans = 0, x;
  while (n > 1) {
    ++ans;
    x = cnt();
    n -= (x + 1) * (3 * x + 4) / 2;
  }
  cout << ans << "\n";
}
int main() {
  fastIOfileinput();
  if (typetest) {
    int t;
    cin >> t;
    while (t--) {
      Enter();
      solve();
    }
  } else {
    Enter();
    solve();
  }
}
