#include <bits/stdc++.h>
using namespace std;
const int N = 3500;
long long a[N], b[N];
void solve() {
  long long a;
  cin >> a;
  int res = 0;
  while (a > 1) {
    int val = (-0.5 + sqrt(0.25 + 6 * a)) / 3;
    a -= (val * (val + 1)) + ((val - 1) * (val)) / 2;
    res++;
  }
  cout << res << endl;
}
int main() {
  int T;
  scanf("%d", &T);
  for (int i = 0; i < int(T); ++i) solve();
}
