#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long llp;
#define mod 1000000007
#define deb(x) cerr << '\t' << "[" << #x << ": "<< x << "]\n";
#define fi first
#define se second
#define pb push_back

void solution();
int main() {
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	llp tc = 1;
	cin >> tc;
	for(llp t = 0; t < tc; ++t) {
		//cout << "Case #" << t + 1 << ": ";
		solution();
		cerr << "-------------------\n";
	}
}

void solution() {
	int n;
	cin >> n;
	int z = __builtin_clz(n);
	//deb(32 - z);
	int y = 32 - z - 1;
	cout << (1 << y) - 1 << '\n';
}
