/*                 -> Bismillahir Rahmanir Rahim <-                */
/*
    Motto - Try Hard To become -> specialist <-  :)
*/

#include<bits/stdc++.h>
using namespace std;
//Some Hints
//Find odd and even return 1 || 0
// __builtin_parity() if x is ll use __builtin_parityll(x)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
// count how many 0 in a bynary number
#define NumOf0(x) __builtin_popcount(x)
// count how many 1 in a bynary number
#define NumOf1(x) __builtin_ctz(x)
#define   all(v)   v.begin(), v.end()
#define pi acos(-1)
typedef  long long ll;
#define MOD  1000000007
typedef  unsigned long long ull;
typedef  unsigned un;
#define Bismilla ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define In insert
#define ln "\n"
//); ... Don't Stop The Party ... :)


void solve()
{
   ll n, m, k,cnt=0;
   cin>>n;
   while (n>0)
   {
       cnt++;
       n=n/2;
   }
   cout<<(ll)pow(2,cnt-1)-1<<ln;
   
   
}

int main()
{
   //Bismilla;
   int t=1;
   cin>>t;
   while(t--)solve();
}

