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

int main(){
	long long int t;
	cin>>t;
	while(t--){
		long long int n;
		cin>>n;
		int i=0;
		while(1){
			if((long long)pow(2,i)>n){
				break;
			}
			i++;
		}
		cout<<(long long)((long long)pow(2,i-1)-1)<<endl;
	}
	return 0;
}