#include <bits/stdc++.h>
using namespace std;
long long int x, a, b, c, t, k, tests, temp, y, l, r, d, n, m;
void swap(long long int& a, long long int& b) {
  long long int temp = (a ^ b);
  a = (a ^ temp);
  b = (a ^ temp);
}
int main(int argc, const char* argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> tests;
  while (tests--) {
    cin >> n;
    long long int remaining = n;
    long long int cnt = 0;
    while (remaining > 1) {
      n = remaining;
      cnt++;
      long long int height = (-1 + sqrt(1 + 24 * n)) / 6;
      long long int required = ((3 * height * height) + height) / 2;
      remaining = n - required;
    }
    cout << cnt << endl;
  }
  return 0;
}
