#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  set<long long> ss;
  for (int i = 1; i <= 1e6; i++) {
    long long need = i * 2;
    long long cards = (i * (i + 1)) / 2;
    long long lft = cards - i;
    need += lft * 3;
    if (need > 1e9) break;
    ss.insert(-need);
  }
  while (t--) {
    long long n;
    cin >> n;
    long long cnt = 0;
    while (true) {
      set<long long>::iterator it = ss.lower_bound(-n);
      if (it == ss.end()) break;
      cnt++;
      n += *it;
    }
    cout << cnt << '\n';
  }
  return 0;
}
