#include <bits/stdc++.h>
using namespace std;
long long int find(long long int n) {
  long long int start = 1;
  long long int end = n / 2;
  long long int ans = 0;
  while (start <= end) {
    long long int mid = (start + end) / 2;
    long long int card = mid * (mid + 1) + ((mid - 1) * mid) / 2;
    if (card <= n) {
      ans = card;
      start = mid + 1;
    } else {
      end = mid - 1;
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  long long int t, n, m, i, j, k;
  cin >> t;
  while (t--) {
    cin >> n;
    long long int ans = 0;
    while (n > 1) {
      k = find(n);
      ans += 1;
      n -= k;
    }
    cout << ans << endl;
  }
  return 0;
}
