#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define EE 1e-6
using namespace std;
const int INF = 0x7fffff4;
typedef long long ll;
typedef pair<int,int> P;
const int N=51;
int n;
int a[N];
int main(){
    IOS
    int t;
    cin>>t;
    while(t--){
        cin>>n;
        int cnt=0;
        while(n) n>>=1,cnt++;
        //cout<<cnt<<endl;

        cout<<((1<<(cnt-1))-1)<<endl;
    }
    return 0;
}

  	 	 			    	  	 		 	  	 				