#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
ll mod = 1e9+7;

int main()
{
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        
        if((n&(n-1))==0){
            cout << n-1 << endl;
            continue;
        }
        int po = 0;
        int t = 1;
        while(t*2<n){
            po++;
            t*=2;
        }
        cout << (int)pow(2, po) - 1 << endl;
    }
}
