#include <bits/stdc++.h>
using namespace std;
long long dp[100005];
long long solve() {
  long long n;
  cin >> n;
  long long cnt = 0;
  long long pos = 0;
  while (pos < 100005 && dp[pos] <= n) pos++;
  for (long long i = pos; i >= 0; i--) {
    while (n - dp[i] >= 0) {
      n -= dp[i];
      cnt++;
    }
  }
  cout << cnt << "\n";
  return 0;
}
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  dp[0] = 2;
  for (long long i = 1; i < 100005; i++) dp[i] = dp[i - 1] + (i + 1) * 3 - 1;
  long long t = 1;
  cin >> t;
  while (t-- != 0) {
    long long stat = solve();
  }
  return 0;
}
