#include <bits/stdc++.h>
inline void read(int &T) {
  int x = 0;
  bool f = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = !f;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  T = f ? -x : x;
}
int t, h[30001];
int main() {
  h[1] = 2;
  for (int i = 2; i <= 30000; ++i) {
    h[i] = h[i - 1] + (i - 1) + 2 * (i);
  }
  read(t);
  while (t--) {
    int ans = 0, x;
    read(x);
    for (int i = 30000; i >= 1; --i) {
      if (x >= h[i]) {
        ans += x / h[i];
        x -= x / h[i] * h[i];
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
