#include <bits/stdc++.h>
using namespace std;
int c = 0;
long long int cardsReq(long long int h) {
  long long int n = (3 * h * h + h) / 2;
  return n;
}
long long int height(long long int n) {
  long long int h = (sqrt(1 + 24 * n) - 1) / 6;
  return h;
}
void solution(long long int n) {
  if (n < 2) {
    cout << c;
    return;
  }
  long long int h = height(n);
  long long int rem = cardsReq(h);
  n = n - rem;
  c++;
  solution(n);
  return;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int n, rem, nt, i;
    cin >> n;
    solution(n);
    c = 0;
    cout << "\n";
  }
}
