#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5, M = N;
long long mpow(long long base, long long exp);
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
void fastIO() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int32_t main() {
  fastIO();
  vector<long long> v;
  for (long long i = 2, cnt = 1; i <= 1e9; cnt++, i += cnt * 2 + (cnt - 1))
    v.emplace_back(i);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long t = 0;
    while (n >= 2) {
      auto it = upper_bound(v.begin(), v.end(), n);
      --it;
      t++;
      n -= *it;
    }
    cout << t << "\n";
  }
  return 0;
}
long long mpow(long long base, long long exp) {
  base %= 1000000007;
  long long result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((long long)result * base) % 1000000007;
    base = ((long long)base * base) % 1000000007;
    exp >>= 1;
  }
  return result;
}
