#include <bits/stdc++.h>
using namespace std;
int const N = 1e5 + 5;
int h[N];
int main() {
  int k = 1;
  h[k] = 2;
  while (2e9 > h[k]) {
    k++;
    h[k] = h[k - 1] + 2 + (k - 1) * 3;
  }
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int i;
    for (i = 1; i <= k; i++)
      if (h[i] > n) {
        i--;
        break;
      }
    int cnt = 0;
    while (n > 1 && i > 0) {
      while (i > 0 && n >= h[i]) n -= h[i], cnt++;
      while (i > 0 && n < h[i]) i--;
    }
    cout << cnt << endl;
  }
  return 0;
}
