#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void f() {
  long long n;
  cin >> n;
  long long ans = 0;
  while (n > 1) {
    long long x = 1;
    while ((3 * x * x + x) / 2 <= n) {
      x++;
    }
    x--;
    n = n - (3 * x * x + x) / 2;
    ans++;
  }
  cout << ans << endl;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    f();
  }
  return 0;
}
