#include <bits/stdc++.h>
using namespace std;
long long const llINF = numeric_limits<long long>::max();
int const INF = numeric_limits<int>::max();
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int T;
  cin >> T;
  for (int repetitions = 0; repetitions < T; repetitions++) {
    int N;
    cin >> N;
    int pyr = 0;
    while (N > 0) {
      int h = 1;
      while (N - (3 * h - 1) >= 0) {
        N -= (3 * h - 1);
        h++;
      }
      if (h == 1) break;
      pyr++;
    }
    cout << pyr << '\n';
  }
}
