#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long count = 0, i = 1, res = 0;
    while (n > 1) {
      res = (3 * pow(i, 2) + i) / 2;
      if (res > n) {
        res = (3 * pow(i - 1, 2) + i - 1) / 2;
        count++;
        n -= res;
        i = 1;
        continue;
      }
      i++;
    }
    cout << count << endl;
  }
  return 0;
}
