#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define pb push_back
#define m 1000000007
ll int power(ll int x, ll int y, ll int p)
{
    ll int res = 1;      // Initialize result
 
    x = x % p;  // Update x if it is more than or
                // equal to p
 
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;
 
        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}
 
// Returns n^(-1) mod p
ll int modInverse(ll int n, ll int p)
{
    return power(n, p-2, p);
}
int main()
{
    std::ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
    ll t;
    cin>>t;
    
    while(t--)
    {
        ll n;
        cin>>n;
        ll i,j;
        ll powt[31];
        powt[0]=1;
        for(i=1;i<31;i++)
        powt[i]=2*powt[i-1];
        for(i=30;i>=0;i--)
        {
            if(powt[i]&n)
            break;
        }
        
        cout<<powt[i]-1<<endl;
    }
    return 0;
}