#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    cin >> n;
    int num = 0;
    int now = 0;
    int ans = 0;
    while (now <= n) {
      num++;
      now = num * (num - 1) / 2 * 3 + num * 2;
    }
    num--;
    while (n >= 2 && num >= 1) {
      now = num * (num - 1) / 2 * 3 + num * 2;
      if (n >= now) {
        n -= now;
        ans++;
        num++;
      }
      num--;
    }
    cout << ans << endl;
  }
  return 0;
}
