#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a = 2, f;
  int T;
  cin >> T;
  for (int i = 0; i < T; i++) {
    f = 0;
    cin >> n;
    while (a <= n) {
      n = n - a;
      a = a + 3;
      if (a > n) {
        f = f + 1;
        a = 2;
      }
    }
    cout << f << endl;
  }
  return 0;
}
