#include <bits/stdc++.h>
using namespace std;
long long calculate(int n) {
  long long l, h, mid;
  long long p, q;
  l = 1;
  h = 1e5;
  if (n < 2) return -1;
  while (l <= h) {
    mid = (l + h) / 2;
    p = (3 * mid * (mid + 1)) / 2;
    p -= mid;
    q = (3 * mid * (mid - 1)) / 2;
    q -= mid - 1;
    if (n >= q && n <= p)
      break;
    else if (n > p)
      l = mid + 1;
    else
      h = mid - 1;
  }
  if (n == p)
    return p;
  else if (n == q)
    return q;
  else if (n > q && n < p)
    return q;
  else
    return -1;
}
int main() {
  long long t, n;
  cin >> t;
  while (t--) {
    cin >> n;
    int ch = 1, c = 0;
    long long k;
    while (ch) {
      k = calculate(n);
      if (k == -1)
        ch = 0;
      else {
        n -= k;
        c++;
      }
    }
    cout << c << endl;
  }
  return 0;
}
