#include <bits/stdc++.h>
using namespace std;
vector<long long> dp(10000007);
void solve() {
  dp[0] = 0, dp[1] = 2, dp[2] = 7;
  for (int i = 3; i < 10000007; i++) {
    dp[i] = dp[i - 1] - dp[i - 2] + 3 + dp[i - 1];
  }
}
int main() {
  solve();
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long ans = 0;
    while (n > 1) {
      auto it = lower_bound(dp.begin(), dp.end(), n);
      if (*it == n)
        n -= *it;
      else {
        int ind = it - dp.begin() - 1;
        n -= dp[ind];
      }
      ans++;
    }
    cout << ans << endl;
  }
  return 0;
}
