#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, n, ans, st, end, mid;
  cin >> t;
  for (int q = 0; q < t; q++) {
    cin >> n;
    ans = 0;
    while (n >= 2) {
      st = 1;
      end = 100000;
      while (st <= end) {
        mid = (st + end) / 2;
        if (mid * (3 * mid + 1) / 2 <= n) {
          st = mid + 1;
        } else {
          end = mid - 1;
        }
      }
      n -= end * (3 * end + 1) / 2;
      ans++;
    }
    cout << ans << endl;
  }
  return 0;
}
