#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long t;
  cin >> t;
  ;
  while (t--) {
    long long n;
    cin >> n;
    ;
    long long sum = 0;
    while (n > 1) {
      long long h = floor((sqrt(1 + 24 * n) - 1) / 6);
      n = n - h * (3 * h + 1) / 2;
      sum++;
    }
    cout << sum << endl;
    ;
  }
}
