#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n, i, t, h, it;
  vector<long long int> v;
  v.push_back(2);
  i = 2;
  h = 1;
  while (h <= 1000000000) {
    h = 2 * i + (i - 1) + v[i - 2];
    v.push_back(h);
    i++;
  }
  cin >> t;
  while (t--) {
    cin >> n;
    long long int c = 0;
    while (n > 0) {
      it = lower_bound(v.begin(), v.end(), n) - v.begin();
      if (v[it] == n) {
        c++;
        break;
      } else if (n - v[it - 1] > 0) {
        c++;
        n -= v[it - 1];
      } else
        break;
    }
    cout << c << '\n';
  }
  return 0;
}
