#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
long long int getCnt(long long int h) { return (3 * h * h + h) / 2; }
signed main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    long long int ans = 0;
    while (n > 1) {
      long long int l = 1, r = 1e9;
      while (r - l > 1) {
        long long int mid = (l + r) / 2;
        if (getCnt(mid) <= n)
          l = mid;
        else
          r = mid;
      }
      n -= getCnt(l);
      ans++;
    }
    cout << ans << "\n";
  }
  return 0;
}
