#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int N = 1e6 + 9;

int main () {
    int t;
    cin >> t;
    while (t--) {
        ll n, last;
        cin >> n;
        for (ll i = 0; i < 33; i++) {
            if (n & (1ll << i))
                last = i;
        }
        cout << ((1ll << last) - 1ll) << "\n";
    }
    return 0;
}
