#include <bits/stdc++.h>
using namespace std;
long int a[1000000];
int main() {
  long int t, n, count, j;
  a[0] = 2;
  long int d = 5;
  long int i = 1;
  while (a[i - 1] <= 1000000000) {
    a[i] = a[i - 1] + d;
    d = d + 3;
    i++;
  }
  cin >> t;
  while (t--) {
    cin >> n;
    count = 0;
    i = 0;
    if (n < 2)
      cout << 0 << endl;
    else {
      while (n >= 2) {
        i = 0;
        while (a[i] <= n) i++;
        j = i - 1;
        n = n - a[j];
        count++;
      }
      if (n < 0)
        cout << count;
      else
        cout << count << endl;
    }
  }
}
