#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  vector<long long int> v;
  long long int h = 0, sum = 0;
  while (sum < 1000000001) {
    sum += ((h * 3) + 2);
    v.push_back(sum);
    h++;
  }
  int l = v.size();
  int t;
  cin >> t;
  while (t--) {
    int n, c = 0;
    cin >> n;
    while (n >= 2) {
      int i = 0;
      while (v[i] <= n) i++;
      n -= v[i - 1];
      c++;
    }
    cout << c << endl;
  }
}
