#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int i, j, T, n, x, flag, total, asd, sdf;
  cin >> T;
  long long int arr[1000000];
  while (T--) {
    total = 0;
    cin >> n;
    i = 0;
    arr[0] = 0;
    while (arr[i] <= n) {
      i++;
      arr[i] = (2 * i) + ((3 * i * (i - 1)) / 2);
    }
    i--;
    while (n >= 2 && i > 0) {
      if (arr[i] <= n) {
        n = n - arr[i];
        i++;
        total++;
      }
      i--;
    }
    cout << total << "\n";
  }
  return 0;
}
