#include<bits/stdc++.h>
using namespace std;
 


void output()
{
	long long n;
	cin>>n;
	if(n&(n-1)==0)
		cout<<n-1<<"\n";
	else
	{
		int k = (int)(log2(n));;
		cout<<(1<<k)-1<<"\n";
	}

}
int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
		long long t;
		cin>>t;
		while(t--)
		{
			 output();		     
		}
 
return 0;
}