#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, flag;
  cin >> n;
  long long start = 0, end = n;
  while (start <= end) {
    long long mid = start + (end - start) / 2;
    long long temp = 3 * (mid * (mid + 1)) / 2 - mid;
    if (n >= temp) {
      start = mid + 1;
    } else {
      end = mid - 1;
    }
  }
  int ans = 0;
  while (n > 1) {
    long long temp = 3 * (end * (end + 1)) / 2 - end;
    if (n >= temp) {
      n -= temp;
      ans++;
    } else {
      end--;
    }
  }
  cout << ans << endl;
}
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    solve();
  }
  return 0;
}
