#include <bits/stdc++.h>
using namespace std;
const int N = 30010;
int t, n, m;
long long sum[N];
void init() {
  sum[1] = 2;
  for (int i = 2; i < N; i++) sum[i] = sum[i - 1] + 1ll * 3 * i - 1;
}
int main() {
  init();
  cin >> t;
  while (t--) {
    cin >> n;
    int cnt = 0;
    while (n > 1) {
      int l = upper_bound(sum + 1, sum + N, n) - sum;
      cnt++;
      n -= sum[l - 1];
    }
    cout << cnt << endl;
  }
  return 0;
}
