#include <bits/stdc++.h>
using namespace std;
int binarySearch(long long int arr[], int l, int r, int x) {
  while (l <= r) {
    int m = l + (r - l) / 2;
    if (arr[m] == x) return m + 1;
    if (arr[m] < x)
      l = m + 1;
    else
      r = m - 1;
  }
  return l;
}
int main() {
  int n, t, i, j, p1 = 3, p2 = 0, f;
  long long int oper[200000];
  oper[0] = 2;
  for (i = 1; i < 200000; i++) {
    oper[i] = oper[i - 1] + 3 * (i) + 2;
  }
  cin >> t;
  for (i = 0; i < t; i++) {
    cin >> n;
    f = n;
    while (f > 1) {
      p1 = binarySearch(oper, 0, 200000, f);
      f = f - oper[p1 - 1];
      p2++;
      if (f == 2) {
        f = 0;
        p2++;
      }
    }
    cout << p2 << endl;
    p2 = 0;
  }
  return 0;
}
