//--------
//It's me|
//--------
//author :: Pranav Rajveer
/*
*CS UNDERGRAD AT GGU BILASPUR.
*/
// "TRAIN HARD OR DIE TRYING"
 
#include                 <bits/stdc++.h>
using                    namespace std;
#define ll               long long
#define ff               first
#define eb               emplace_back
#define np(vt)           next_permutation(vt.begin(), vt.end())
#define ss               second
#define llt              long long int
#define all(vt)          (vt.begin(), vt.end())
#define loop(i,a,n)      for(int i=a;i<n;i++)
#define rloop(i,a,n)     for(int i=a;i<=n;i++)
#define loopl(i,a,b)     for(ll i=(ll)a;i<(ll)b;i++)
#define loopr(i,a,b)     for(int i=(int)a;i>=(int)b;i--)
#define pb2              pop_back
#define INF              (1LL<<61)-1
#define pi               3.1415926535897
#define vvit             vector<vector<int>>
#define pb               push_back
#define vpit             vector<pair<int,int>>
#define vpil             vector<pair<ll,ll>>
#define vst              vector<string>
#define vit              vector<int>
#define MOD              1000000
#define vvl              vector<vector<ll>>
#define bpc(a)           __builtin_popcountll(a)
#define vil              vector<ll>
#define speed            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 

//Checking whether my number n is power of 2 or not..
bool isPowerOfTwo(int n)
{
    if (n == 0)
        return false;
 
    return (ceil(log2(n)) == floor(log2(n)));
}
 
// if ( (a/b)*b == a) Checking whether a number is a power of another number or not.
 
 
//Taken from geeks for geeks.
int binarySearch(int arr[], int l, int r, int x)
{
    if (l <= r)
    {
        int mid = l + (r - l) / 2;
 
        // If the element is present at the middle
        // itself
        if (arr[mid] == x)
            return mid;
 
        // If element is smaller than mid, then
        // it can only be present in left subarray
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
 
        // Else the element can only be present
        // in right subarray
        return binarySearch(arr, mid + 1, r, x);
    }
 
    // We reach here when element is not
    // present in array
    return -1;
}
 

//Time Complexity : O(N*LogN)
bool compare_it(pair<int, int> a, pair<int, int> b)
{
    if (a.first == b.first)
        return a.second > b.second;
    return
        a.first > b.first;
}
 
 
 struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

/* NOTES::(Prepared by pranav)

1. if possible try using unordered map with custom_hash or just map to avoid  tle or hacking in codeforces..
2. DO always a second check on integer overflows. Use ll instead of int or string instead of ll.
3. If somehow encounter RE then check whether you are not gng out of bounds or dividing by 0.
4. To reduce TLE due to nested loop try to divide and conquer it .
5. For questions asking min or max of smthng::
  (i) Go for greedy solution if constraints are big and time is tight.
  (ii) Go for dp if u could identify initial state of dp and constraints in problem are small(effectively till 1k)
6. For number theory problems try to generate best possible formula for it.
7. If gettin W.A frequently on your solution then try to do stress test on ur solution.
8. For problems relatd to duplicacy try using set.
9. Memoized dp takes more space than tabulation dp. If space constr. is tight avoid memoized dp.
  (i) Always try to figure out your solution in form of iterative dp (bottom up approach).
  
To be continued...(as I gain more experience will keep adding more)  :)
 */

void solve()
{
 int n;  cin>>n;
        int k=0;
        while(1)
        {
           k=n;
           n&=(n-1);
  if(n==0)
           {
               cout<<k-1<<endl;
               break;
           }
        }
}
 
int main()
{
    speed
   int t;
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}