#include <bits/stdc++.h>
using namespace std;
const int N = 100000;
vector<long long> dp(N);
int main() {
  dp[1] = 2;
  for (long long i = 2; i <= N - 1; i++) {
    dp[i] = i * 2 + dp[i - 1] + i - 1;
  }
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int ans = 0;
    while (1) {
      auto it = lower_bound(dp.begin(), dp.end(), n);
      int i = it - dp.begin();
      if (dp[i] > n) i--;
      if (n <= 1) break;
      ans++;
      n -= dp[i];
    }
    cout << ans << endl;
  }
  return 0;
}
