#include <bits/stdc++.h>
using namespace std;
long long l[30000];
void fun() {
  long long n, cnt = 0;
  scanf("%lld", &n);
  for (int i = 25821; i >= 1; i--) {
    if (n >= l[i]) {
      n -= l[i];
      cnt += 1;
      i++;
    }
    if (n < 2) break;
  }
  printf("%d\n", cnt);
  return;
}
int main() {
  int t;
  l[1] = 2;
  for (int i = 2; i <= 25821; i++) l[i] = l[i - 1] + 3 * i - 1;
  cin >> t;
  while (t--) {
    fun();
  }
  return 0;
}
