#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <map>
#include <stack>
using namespace std;
typedef long long ll;
typedef long long int ull;
typedef vector<int> vi;
typedef vector<ll> vl;
int arr[100005];
void ZeZo()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
}
bool comp(pair<int, int> s, pair<int, int> t)
{
	return s.second < t.second;
}
bool sortByVal(const pair<string, int> &a,
	const pair<string, int> &b) {
	return (a.second > b.second);
}

bool poweroftwo(int n)
{
	return (n > 0) && ((n&(n - 1)) == 0);
}
bool isprime(int x)
{

}
vector<ll> solve(ll n)
{
	vector<ll> ans; 
	ll p = 1; 
	while (n > 0)
	{
		if (n & 1)
		{
			ans.push_back(p);
		}
		n >>= 1; 
		p *= 2; 
	}
	return ans; 


}
void solve()
{
	ll n; 
	cin >> n; 
	vector<ll> v = solve(n);
	int l = v.size(); 
	cout << v[l - 1] - 1<<"\n"; 
}
int main()
{
	ZeZo();
	int t;
	cin >> t;
	while (t--){
		solve();
	}
}

