#include <bits/stdc++.h>
using namespace std;
long long int Lfun(vector<long long int> &v, long long int t) {
  long long int a = -1;
  if (v.size() == 0) return a;
  long long int l = 0, r = v.size() - 1;
  while (l <= r) {
    long long int m = (l + r) / 2;
    if (v[m] <= t) {
      a = v[m];
      l = m + 1;
    } else
      r = m - 1;
  }
  return a;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << setprecision(9) << fixed;
  long long int t;
  cin >> t;
  vector<long long int> v;
  v.push_back(0);
  long long int t2 = 2;
  long long int t3 = 2;
  while (t3 <= 1000000000) {
    v.push_back(t3);
    t2 += 3;
    t3 += t2;
  }
  while (t--) {
    long long int n;
    cin >> n;
    long long int c = 0;
    long long int t1 = 2;
    while (n > 1) {
      long long int t1 = Lfun(v, n);
      n -= t1;
      c++;
    }
    cout << c << endl;
  }
  return 0;
}
