#include <bits/stdc++.h>
using namespace std;
long long int bin_search(long long int n) {
  long long int h, low = 1, high = 100000, mid = 0, mem = 0;
  while (low <= high) {
    mid = (low + high) / 2;
    h = (mid * (3 * mid + 1)) / 2;
    if (h == n)
      return n - h;
    else if (h > n) {
      high = mid - 1;
    } else {
      mem = n - h;
      low = mid + 1;
    }
  }
  return mem;
}
int main() {
  int tc;
  long long int n;
  cin >> tc;
  while (tc-- != 0) {
    cin >> n;
    if (n == 1) {
      cout << "0" << endl;
      continue;
    }
    long long int t = bin_search(n);
    int counter = 1;
    while (t > 1) {
      counter++;
      t = bin_search(t);
    }
    cout << counter << endl;
  }
  return 0;
}
