#include <bits/stdc++.h>
using namespace std;
long long int func(long long int x) {
  long long int val = floor((sqrt(1 + 24 * x) - 1) / 6);
  return val;
}
int main() {
  long long int T;
  cin >> T;
  while (T--) {
    long long int n;
    cin >> n;
    long long int cnt = 0;
    long long int biggest = func(n);
    while (biggest != 0) {
      cnt++;
      n -= (3 * biggest * biggest + biggest) / 2;
      biggest = func(n);
    }
    cout << cnt << "\n";
  }
}
