#include <bits/stdc++.h>
using namespace std;
const int M = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout.setf(ios::fixed);
  cout.precision(20);
  long long int t, n;
  cin >> t;
  while (t--) {
    long long int idx;
    cin >> n;
    int cnt = 0;
    while (n >= 2) {
      long long int i = 1;
      while ((3 * i * i + i) / 2 <= n) {
        i++;
      }
      i--;
      long long int sum = (3 * i * i + i) / 2;
      cnt++;
      n -= sum;
    }
    cout << cnt << '\n';
  }
}
