#include <bits/stdc++.h>
using namespace std;
int main() {
  long long q;
  cin >> q;
  while (q--) {
    long long n, i, x, cnt = 0;
    cin >> n;
    while (n) {
      x = n * 2 / 3;
      x = sqrt(x);
      long long d = (((x * (x + 1)) / 2) * 3) - x;
      if (x == 0 || d == 0) break;
      if (d > n) {
        x--;
        d = (((x * (x + 1)) / 2) * 3) - x;
      }
      n -= d;
      cnt++;
    }
    cout << cnt << endl;
  }
}
