#include <bits/stdc++.h>
using namespace std;
int t, n, p[26001], j, nrt, u;
int cauta(int st, int dr) {
  int poz, mij;
  while (st <= dr) {
    mij = (st + dr) / 2;
    if (p[mij] <= n) {
      poz = mij;
      st = mij + 1;
    } else
      dr = mij - 1;
  }
  return poz;
}
int main() {
  cin >> t;
  for (int tt = 1; tt <= t; tt++) {
    cin >> n;
    j = p[0] = nrt = 0;
    while (p[j] < n) {
      j++;
      p[j] = p[j - 1] + j * 3 - 1;
    }
    u = j;
    while (n >= 2) {
      j = cauta(1, u);
      u = j;
      while (p[j] <= n) {
        n -= p[j];
        nrt++;
      }
    }
    cout << nrt << endl;
  }
  return 0;
}
