#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long x;
    cin >> x;
    int kq = 0;
    while (x >= 2) {
      long long l = 0, r = 10000000;
      while (true) {
        long long m = (l + r) / 2;
        if (m * (m + 1) / 2 * 3 - m <= x)
          l = m;
        else
          r = m;
        if (l + 1 == r) break;
      }
      kq++;
      x -= l * (l + 1) / 2 * 3 - l;
    }
    cout << kq << '\n';
  }
  return 0;
}
