#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll t;
    cin >> t;
    while (t--)
    {
        double n;
        cin >> n;
        ll c = ceil(log2(n));
        ll f = floor(log2(n));
        if (c == f)
            cout << n - 1 <<"\n";
        else
        {
            cout << (1 << f) - 1 << "\n";
        }
    }
}