#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
const long long INF = 0x3f3f3f3f;
const long long NINF = -INF - 1;
const double PI = acos(-1);
const long long mod = 998244353;
const long long maxn = 5e4 + 10;
using namespace std;
long long m[maxn];
long long cnt;
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  for (long long i = 1; i * (i + 1) / 2 * 3 - i <= 1e9; i++)
    m[i] = i * (i + 1) / 2 * 3 - i;
  sort(m + 1, m + 25819 + 1, greater<long long>());
  long long t;
  cin >> t;
  while (t--) {
    long long n, ans = 0;
    cin >> n;
    while (n > 1) {
      long long pos =
          lower_bound(m + 1, m + 25819 + 1, n, greater<long long>()) - m;
      n -= m[pos];
      ans++;
    }
    cout << ans << '\n';
  }
  return 0;
}
