#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 

typedef long long int ll;
typedef unsigned long long int ull;
#define vi vector<int>
#define vll vector< ll >
#define vull vector< ull >
#define vvi vector< vi >
#define vvll vector < vll >
#define vvull vector < vull >
#define mii map<int,int>
#define pii pair< int , int >
#define vpii vector< pii >
#define repeat(n) for(int ajsS32D_v = 0 ; ajsS32D_v < (n) ; ajsS32D_v++)
#define forn(i,n) for(ll (i) = 0LL ; (i) < (n) ; (i)++)
#define rep(i,a,b) for(int (i) = (a) ; (i) <= (b) ; (i)++)
#define rrep(i,a,b) for(int (i) = (a) ; (i)>= (b) ; (i)--)
#define debug(x) cerr <<"\n--------------"<< #x << " is " << x << "--------------\n"
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin() , (x).end()
#define mod (ll)1000000007
#define INF (ll)1
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define LL_MAX (ll)9223372036854775807
#define ld long double
#define PI (ld)3.1415926535897932384626433832795028
//#define stopwatch
#ifdef stopwatch
#include<chrono>
using namespace std::chrono;
#endif
using namespace std ;
//For ordered set
// using namespace __gnu_pbds; 
// template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
template<typename T>
void spit(vector<T> a){
	for(auto i : a)cout << i << " ";
		cout << "\n";
}
template<typename T>
void maxa(T& a, T b){
	a = max(a,b);
}
template<typename T>
void mina(T& a, T b){
	a = min(a,b);
}
int nxt(){
	int a ;
	cin >> a ;
	return a;
}
ll nxtll(){
	ll a ;
	cin >> a ;
	return a;
}
ll gcd(ll a , ll b){
    if(a==0LL || b == 0LL )return 1LL;
    if(a %b == 0LL)
        return b ;
    return gcd(b , a%b);
}
void solve(){
	ll n ;
	cin >> n ;
	ll ans = 1LL;
	while(ans*2LL <= n){
		ans *= 2LL;
	}
	cout << ans -1LL << endl;
}


int main(){
	FASTIO ;
	#ifdef stopwatch
		auto startaaaa = high_resolution_clock::now(); 
	#endif
	

	bool multi_run =1;
	//freopen("input.txt", "r", stdin);// freopen("output.txt", "w", stdout);
	if(multi_run){
		int t ;
		cin >> t;
		while(t--)solve();
	}else{
		solve();
	}
	cout << flush;
	#ifdef stopwatch
		auto stopaaaa = high_resolution_clock::now();
		auto durationaaaa = duration_cast<microseconds>(stopaaaa - startaaaa)/1000.0;
		cout << "Execution Time: "<< durationaaaa.count() << " milliseconds" << endl; 
	#endif

}
