#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll ,ll>
using namespace std ;
const ll z = 998244353 ;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("inputf.txt" , "r" , stdin) ;
freopen("outputf.txt" , "w" , stdout) ;
freopen("error.txt" , "w" , stderr) ;
#endif
int t ;
cin >> t ;
while(t--)
{
int n ;
cin >> n ;
ll ans = 0 ;
for(int i = 32 ; i >= 0 ; i--)
{
if((((1LL) << i) & n) != 0)
{
ans = i ;
break ;
}
}
ll fin_ans = (n-1 - ans) ;
cout << fin_ans << endl ;
}
return 0;
}