#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  vector<long long> v;
  long long h = 1, m;
  while (h <= 25820) {
    m = ((3 * h + 1) * h) / 2;
    v.push_back(m);
    h++;
  }
  for (long long j = 0; j < t; j++) {
    long long n, pos = 0;
    cin >> n;
    for (long long i = 0; i < v.size(); i++) {
      if (n <= v[i]) {
        pos = i;
        break;
      }
    }
    long long ans = 0;
    while (n > 0 && pos >= 0) {
      ans += (n / v[pos]);
      n %= v[pos];
      pos--;
    }
    cout << ans << "\n";
  }
  return 0;
}
