#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
int f[N];
void init() {
  for (int i = 1; i <= N; i++) {
    f[i] = f[i - 1] + i * 2 + (i - 1);
    if (f[i] >= 1e9) {
      break;
    }
  }
}
int Find(int x) {
  int l = 0, r = 25820;
  while (l < r) {
    int mid = (l + r + 1) / 2;
    if (f[mid] <= x)
      l = mid;
    else
      r = mid - 1;
  }
  return l;
}
int main() {
  int T;
  scanf("%d", &T);
  init();
  while (T--) {
    int x;
    scanf("%d", &x);
    int ans = 0;
    while (true) {
      int t = Find(x);
      if (f[t] <= 0) break;
      x -= f[t];
      ans++;
    }
    printf("%d\n", ans);
  }
  return 0;
}
