#include <bits/stdc++.h>
using namespace std;
int t, n, a[10000010], z;
int getnum(int n) {
  for (int i = 1;; i++) {
    if (a[i] > z) {
      z -= a[i - 1];
      break;
    }
  }
  return z;
}
int main(void) {
  cin >> t;
  int count = 5;
  a[1] = 2;
  for (int i = 2; a[i - 1] <= 1000000001; i++) {
    a[i] += a[i - 1] + count;
    count += 3;
  }
  while (t--) {
    cin >> z;
    int time = 0;
    while (z >= 2) {
      z = getnum(z);
      time++;
    }
    cout << time << endl;
  }
  return 0;
}
