#include <bits/stdc++.h>
using namespace std;
int arr[30001] = {
    2,
};
int main(int argc, char *argv[]) {
  for (int i = 1; i <= 30000; i++) arr[i] = arr[i - 1] + 3 * i + 2;
  int T;
  scanf("%d", &T);
  while (T--) {
    int N;
    scanf("%d", &N);
    int cnt = 0;
    while (N >= 2) {
      cnt++;
      N -= arr[upper_bound(arr, arr + 30000, N) - 1 - arr];
    }
    printf("%d\n", cnt);
  }
}
