#include <bits/stdc++.h>
using namespace std;
long long counts(long long arr[], long long target, long long end) {
  int start = 0;
  int ans = -1;
  while (start <= end) {
    long long mid = (start + end) / 2;
    if (arr[mid] > target)
      end = mid - 1;
    else {
      ans = arr[mid];
      start = mid + 1;
    }
  }
  return ans;
}
int main() {
  long long t, d = 5, i;
  cin >> t;
  long long a[100000];
  a[0] = 2;
  for (i = 1; i < 100000; i++) {
    a[i] = a[i - 1] + d;
    d += 3;
  }
  while (t > 0) {
    long long n, s = 0;
    cin >> n;
    while (n >= 2) {
      long x = counts(a, n, 100000);
      if (x == -1) break;
      n = n - x;
      s++;
    }
    cout << s << "\n";
    --t;
  }
  return 0;
}
