#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, n, m, x1, x2, y1, y2;
  cin >> t;
  while (t--) {
    cin >> n;
    long long count = 0;
    while (n >= 2) {
      int i;
      for (i = 1;; i++) {
        long long temp = (3 * pow(i, 2) + i) / 2;
        if (temp <= n) {
          continue;
        } else {
          break;
        }
      }
      count++;
      n = n - (3 * pow(i - 1, 2) + i - 1) / 2;
    }
    cout << count << endl;
  }
}
