#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T, c, D, ans, h;
  cin >> T;
  while (T--) {
    ans = 0;
    cin >> c;
    while (c) {
      D = sqrt(1LL * 24 * c + 1);
      h = (D - 1) / 6;
      if (h)
        ans++;
      else
        break;
      c -= h * (h + 1) + h * (h - 1) / 2;
    }
    cout << ans << '\n';
  }
  return 0;
}
