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

typedef long long ll;
#define endll "\n"
int main() {
    // your code goes here
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while(t--)
    {
        ll n, i;
        cin >> n;
        ll ans = n;
        for(i = 1 ; i <= n ; i=i*2)
        {
            ans = i;
        }
        cout << ans - 1 << endl;
    }
    return 0;
}