#include <bits/stdc++.h>
using namespace std;
int max_height(long long n) { return (long long)(sqrt(24 * n + 1) - 1) / 6; }
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    int pyramids = 0;
    while (1) {
      long long height = max_height(n);
      if (!height) break;
      long long int cards = (3 * height + 1) * height / 2;
      pyramids += n / cards;
      n -= n / cards * cards;
    }
    cout << pyramids << endl;
  }
  return 0;
}
