#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int MAXH = (int)sqrt(n);
    int ans = 0;
    for (int i = MAXH; i >= 1; i--) {
      long long cards = (long long)i * (3 * i + 1) / 2;
      while (cards <= (long long)n) {
        n -= (int)cards;
        ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
