#include <bits/stdc++.h>
using namespace std;
long long md = 1000000007;
long long bexp(long long a, long long b) {
  if (b == 0) return 1;
  if (b == 1) return a;
  long long r = bexp(a, b / 2);
  r = r * r;
  if (b % 2 == 0)
    return r;
  else
    return r * a;
}
long long bs(vector<long long> v, long long n, long long k) {
  long long l = 0, r = n, mid = 0, ans = -1;
  while (l <= r) {
    mid = (l + r) / 2;
    if (v[mid] > k) {
      r = mid - 1;
    } else {
      ans = mid;
      l = mid + 1;
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int test_case = 1;
  vector<long long> v;
  for (long long i = 1; i <= 100000; i++) {
    long long yy = (3 * i * i + i) / 2;
    v.push_back(yy);
  }
  cin >> test_case;
  while (test_case--) {
    long long n, sum = 0, cnt = 0, m = 0, i = 0, ans = 0, j;
    long long p = 0, l = 0, q = 0, r = 0, x = 0, y = 0, k = 0, d = 0;
    cin >> n;
    long long flag = 0;
    ans = 0;
    auto it = upper_bound(v.begin(), v.end(), n);
    if (it != v.end()) {
      p = it - v.begin();
    } else {
      p = v.size() - 1;
    }
    while (n > 1) {
      if (n >= v[p]) {
        ans++;
        n = n - v[p];
      } else {
        p--;
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
