#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, h, i, p;
  int n;
  cin >> t;
  for (i = 0; i < t; i++) {
    cin >> n;
    p = 0;
    while (n) {
      h = 0;
      while (n >= (h * (3 * h + 1)) / 2) h++;
      h--;
      if (h > 0) {
        n = n - (h * (3 * h + 1)) / 2;
        p++;
      } else if (h == 0)
        break;
    }
    cout << p << endl;
  }
}
