#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, i;
  cin >> t;
  long long int a[100000];
  a[0] = 0;
  for (i = 1; i < 100000; i++)
    a[i] = 2 + (i - 1) * 5 + (((i - 1) * (i - 2)) / 2) * 3;
  while (t--) {
    long long int n, j;
    cin >> n;
    long double count = 0;
    for (i = 0; i < n; i++) {
      if (a[i] > n) break;
    }
    for (j = i - 1; j >= 0; j--) {
      if (n == 1 || n == 0) break;
      count = count + n / a[j];
      n = n % a[j];
    }
    cout << count << " ";
    cout << "\n";
  }
}
