#include <bits/stdc++.h>
using namespace std;
vector<int> ans;
constexpr double PI = 3.14159265358979323846;
unordered_map<int, int> mp;
int solve() { return 0; }
int main() {
  int t, z;
  const int m = 1e9;
  vector<long long> v;
  for (long long i = 0; i <= sqrt(m); i++) {
    v.push_back((3 * i * i + i) / 2);
  }
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    int ans = 0;
    while (n >= 2) {
      ans++;
      ;
      int j = upper_bound(v.begin(), v.end(), n) - v.begin();
      n -= v[j - 1];
    }
    cout << ans << endl;
  }
}
