#include <bits/stdc++.h>
using namespace std;
void print(long long *arr, int n) {
  for (int i = 0; i < n; i++) cout << i + 1 << "\t" << arr[i] << endl;
}
int search(long long *dp, long long n) {
  int start = 0, end = 26000, ans = 0;
  while (start <= end) {
    int mid = (start + end) / 2;
    if (dp[mid] > n)
      end = mid - 1;
    else {
      ans = mid;
      start = mid + 1;
    }
  }
  return ans;
}
int main() {
  int t = 0;
  cin >> t;
  long long *dp = new long long[26001];
  for (int i = 0; i < 26001; i++) {
    int c = i + 1;
    dp[i] = ((3 * c * c) + c) / 2;
  }
  while (t--) {
    long long n = 0, ans = 0;
    cin >> n;
    while (n > 1) {
      int temp = search(dp, n);
      n -= dp[temp];
      ans++;
    }
    cout << ans << endl;
  }
  return 0;
}
