#include <bits/stdc++.h>
using namespace std;
const long long max_n = 1000000000;
vector<int> serie;
long long ans;
void funct(long long n) {
  long long r = serie.size() - 1;
  long long mid;
  while (n >= 2) {
    long long temp = 0;
    long long l = 0;
    while (l <= r) {
      mid = (l + r) / 2;
      if (serie[mid] > n) {
        r = mid - 1;
      } else {
        l = mid + 1;
        temp = mid;
      }
    }
    ans++;
    n = n - serie[temp];
    r = mid;
  }
}
int main() {
  int t;
  cin >> t;
  serie.clear();
  serie.push_back(2);
  long long a = 5;
  while (serie[serie.size() - 1] <= max_n) {
    long long temp = serie[serie.size() - 1] + a;
    serie.push_back(temp);
    a += 3;
  }
  for (int i = 0; i < t; i++) {
    ans = 0;
    long long n;
    cin >> n;
    funct(n);
    cout << ans << endl;
  }
}
