#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t;
    cin>>t;
    while(t--)
    {
        ll n,count=0;
        cin>>n;

        n/=2;

        while (n) 
        {
            n/=2;
            count++;
        }

        cout<<(1<<count)-1<<endl;

    }

    return 0;
}
