#include <iostream>
using namespace std;
 
int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--)
	{
	    int n;
	    cin>>n;
	    if(n < 2)
	    {
	        cout<<0<<endl;
	        continue;
	    }
	    int val;
	    for(int i=2;;i=i*2)
	    {
	        if(n / i == 0)
	        {
	            val = i/2;
	            break;
	        }
	    }
	    int val2 = n % val;
	    cout<<n - (val2+1)<<endl;
	}
	return 0;
}