#include <bits/stdc++.h>
using namespace std;
long long N[100000];
int main() {
  int t;
  long long n;
  cin >> t;
  while (t--) {
    cin >> n;
    long long height = 1;
    while (1) {
      N[height] = 2 * height + ((3 * height) * (height - 1)) / 2;
      if (N[height] > n) break;
      height++;
    }
    int cnt = 0;
    bool possible;
    while (1) {
      for (long long h = height - 1; h > 0; --h) {
        possible = false;
        if (N[h] <= n) {
          cnt++;
          n -= N[h];
          possible = true;
          break;
        }
      }
      if (!possible) break;
    }
    cout << cnt << '\n';
  }
  return 0;
}
