#include <bits/stdc++.h>
using namespace std;
int t;
long long i, j;
long long n, m, k, p, c = 0;
int a[500001];
int main() {
  cin >> t;
  for (i = 1; i <= 500000; i++) {
    a[i] = i * (i + 1) + i * (i - 1) / 2;
  }
  while (t--) {
    cin >> n;
    while (n > 1) {
      for (i = 1; i <= 500000; i++) {
        if (n < a[i]) {
          n -= a[i - 1];
          c++;
          break;
        }
      }
    }
    cout << c << endl;
    c = 0;
  }
  return 0;
}
