#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 1;
bool tang(long long &n) {
  long long l = 0, r = M, kq = 0;
  while (l <= r) {
    long long m = (l + r) / 2;
    long long tan = 2 * (m * (m + 1) / 2) + (m * (m - 1) / 2);
    if (tan <= n) {
      kq = m;
      l = m + 1;
    } else {
      r = m - 1;
    }
  }
  if (kq == 0) {
    n = -1;
    return false;
  } else {
    n = (n - (2 * (kq * (kq + 1) / 2) + (kq * (kq - 1) / 2)));
    return true;
  }
}
void sol() {
  long long n;
  cin >> n;
  int d = 0;
  while (n != -1) {
    if (tang(n) == true)
      d++;
    else
      break;
  }
  cout << d << '\n';
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    sol();
  }
  return 0;
}
