/*  
KEEP GRINDING 🤞🤞🤞- @anujy798


      while(!Good) {
          
           Grind();
     }

*/
#include<bits/stdc++.h>
         using namespace std;
#define int             long long int
#define all(x)         (x).begin(),(x).end()
#define aln(x,n)       (x),(x)+n
#define pub            push_back
#define pol(x)         __builtin_popcountll(x) 
#define redBull        ios_base:: sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define nel            cout<<"\n";

/*-------------***********************************************************--------------------*/
// EUCLIDEAN GCD:-  
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
// SIEVE OF ERASTHOTHENES:-CREATING A PREFIX ARRAY FOR FINDING PRIMES:-
bool prime[100001];
void sieve()
{  
memset(prime, true, sizeof(prime));
for(int i = 2; i < 100001; i++) {
if(prime[i]) {
for(int j= i*i; j<100001; j+=i) {
  prime[i] = false;
}
  } } }
 
int log(int a,int b) {
  return log(a)/log(b);
}            
bool comp(pair<int,int> a,pair<int,int> b) {
  return a.first> b.first;
}
int lcm(int a,int b) {
  return a*b/gcd(a,b);
}

int dp[10001]={0};

/*------------************************************************************------------------*/
void sol()
{
int n;
cin>>n;
if(n==1) {
  cout<<0;
  return;
  }
int x= log2(n);

int y= pow(2,x);

cout<<y-1;





}

/*-----------************************************************************------------------------*/
int32_t  main()
{ /*
 #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif  */
redBull
//sieve();
int tc;
tc=1;
cin>>tc;
while(tc--) {
sol();
nel
}

cerr << "Execution Time : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
return 0;



}