#include <bits/stdc++.h>
inline long long f(long long x) { return (x * (x + 1)) + ((x - 1) * x) / 2LL; }
long long tallest(long long x) {
  long long lo = 1, hi = x;
  long long ans = 0;
  while (lo <= hi) {
    long long mid = lo + (hi - lo) / 2;
    if (f(mid) <= x) {
      ans = mid;
      lo = mid + 1;
    } else {
      hi = mid - 1;
    }
  }
  return ans;
}
int main() {
  int t, n;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    long long res = 0;
    long long h = 0;
    while (1) {
      h = tallest(n);
      if (h == 0) break;
      res++;
      n -= f(h);
    }
    printf("%lld\n", res);
  }
  return 0;
}
