#include <bits/stdc++.h>
#include<limits>
using namespace std;
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define FASTIO   ios_base::sync_with_stdio(false);cin.tie(NULL);
#define unmap unordered_map
#define pb push_back
ll max2(ll x, ll y) {
	if (x > y)
		return x;
	else
		return y;
}
ll min2(ll x, ll y) {
	if (x < y)
		return x;
	else
		return y;
}
ll gcd(ll a, ll b) {
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
void solve(){

    unsigned ll n;
    cin>>n;
    unsigned ll p=1,sum=0;

    while(n>1){
        sum+=p;
        p*=2;
        n>>=1;
    }
    cout<<sum<<endl;
}

int main() {
	FASTIO
	ll t = 1;
	int q = 0;


	cin >> t;

	while (t--) {
            solve();
	}

	return 0;

}


