#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+5;
#define pb push_back
int n,m,t;
int i,j,k;
int a[N];
int b[N],c[N];
vector<int> ans;
vector<int>v[N];
int vis[N];
 
signed main()
{
    int t;
    cin>>t;
    while(t--){
    	int n;
		cin>>n;
		int m=(n-1);
		int f=sqrt(2*m+1);
	//	cout<<f<<endl;
		if(f<3) cout<<0<<endl;
		else cout<<(f-1)/2<<endl;
	}
    return 0;
}