#include <bits/stdc++.h>
using namespace std;
long long int dp[100001];
void initialize() {
  dp[1] = 2;
  for (int i = 2; i <= 100000; i++) {
    dp[i] = dp[i - 1] + 3 * i - 1;
  }
}
int binarysearch(int l, int r, long long int n) {
  if (r > l) {
    if (r == l + 1) {
      if (dp[r] == n) {
        return r;
      } else {
        return l;
      }
    }
    int mid = (r - l) / 2 + l;
    if (dp[mid] == n) {
      return mid;
    } else if (dp[mid] > n) {
      return binarysearch(l, mid, n);
    } else {
      return binarysearch(mid, r, n);
    }
  }
}
int main() {
  int t;
  cin >> t;
  initialize();
  while (t--) {
    long long int n;
    cin >> n;
    if (n < 2) {
      cout << "0" << endl;
      continue;
    }
    int count = 0, a;
    while (n >= 2) {
      a = binarysearch(0, 100000, n);
      n = n - dp[a];
      count++;
    }
    cout << count << endl;
  }
  return 0;
}
