#include <bits/stdc++.h>
using namespace std;
int _, n, psum[25821];
void pre() {
  psum[0] = 0;
  for (int i = 1; i < 25821; ++i)
    psum[i] = 2 + (i - 1) * 5 + ((i - 1) * (i - 2) * 3) / 2;
}
void solve() {
  auto pos = upper_bound(psum, psum + 25821, n) - 1;
  int idx = (int)(pos - psum), cnt = 0;
  while (n > 0 && idx != 0) {
    if (psum[idx] <= n) {
      n -= psum[idx], ++cnt;
      pos = upper_bound(psum, psum + 25821, n) - 1;
      idx = (int)(pos - psum);
    } else
      --idx;
  }
  printf("%d\n", cnt);
}
int main() {
  pre();
  for (scanf("%d", &_); _; _--) {
    scanf("%d", &n);
    solve();
  }
}
