print(function(a, b){
	var i, l, ans=-1e20, t=-1;

	if(b===0){
		ans=[];
		for(i=0; i<a; i++){
			ans.push('o');
		}
		return a*a + '\n' + ans.join('');
	}

	for(i=1, l=Math.min(a+1, b); i<=l; i++){
		var bx=Math.floor(b/i);
		var bi=b%i;
		var ai=i<=2 ? 0 : i-2;
		var ax=a-ai;
		var x = ax*ax+ai - (bx+1)*(bx+1)*bi - bx*bx*(i-bi);
		if(x>ans){
			ans=x;
			t=i;
		}
	}

	var bx=Math.floor(b/t);
	var bi=b%t;
	var ai=t<=2 ? 0 : t-2;
	var ax=a-ai;
	var sb1=repeat(bx+1, 'x');
	var sb2=repeat(bx, 'x');

	var ans2='';
	for(i=0; i<t; i++){
		ans2+= (i<bi?sb1:sb2)+(i<ai?'o':i===ai?repeat(ax, 'o'):'');
	}
	return ans+'\n'+ans2;
}.apply(0, readline().split(' ').map(Number)));
function repeat(n, c){
	var s='';
	while(n--) s+=c;
	return s;
}

print(function(a, b){
	if(b===0){
		var ans=[];
		for(var i=0; i<a; i++){
			ans.push('o');
		}
		return a*a + '\n' + ans.join('');
	}
	var ans=-1e20;
	var t=-1;
	for(var i=1, l=Math.min(a+1, b); i<=l; i++){
		var bx=Math.floor(b/i);
		var bi=b%i;
		var ai=i<=2 ? 0 : i-2;
		var ax=a-ai;
		var x = ax*ax+ai - (bx+1)*(bx+1)*bi - bx*bx*(i-bi);
		if(x>ans){
			ans=x;
			t=i;
		}
		// else{
		// 	break;
		// }
	}

	var bx=Math.floor(b/t);
	var bi=b%t;
	var ai=t<=2 ? 0 : t-2;
	var ax=a-ai;

	var aa=[];
	var bb=[];
	var sb1=repeat(bx+1, 'x');
	var sb2=repeat(bx, 'x');
	for(var i=0; i<bi; i++){
		bb.push(sb1);
	}
	for(var i=0; i<b-bi; i++){
		bb.push(sb2);
	}
	for(var i=0; i<ai; i++){
		aa.push('o');
	}
	aa.push(repeat(ax, 'o'));
	aa.push('');

	var ans2=[];
	for(var i=0; i<t; i++){
		ans2.push(bb[i]);
		ans2.push(aa[i]);
	}
	return ans+'\n'+ans2.join('');
}.apply(0, readline().split(' ').map(Number)));
function repeat(n, c){
	var s='';
	while(n--) s+=c;
	return s;
}

print(function(a, b){
	if(a===0){
		var ans=[];
		for(var i=0; i<b; i++){
			ans.push('x');
		}
		return -b*b + '\n' + ans.join('');
	}
	if(b===0){
		var ans=[];
		for(var i=0; i<a; i++){
			ans.push('o');
		}
		return a*a + '\n' + ans.join('');
	}
	var ans=-1e20;
	var t=-1;
	for(var i=0,l=Math.min(a+1, b); i<l; i++){
		var bx=Math.floor(b/(i+1));
		var bi=b%(i+1);
		var ax=i===0?a:a-i+1;
		var ai=Math.max(0, i-1);
		var x=ax*ax+ai  -  (bx+1)*(bx+1)*bi-bx*bx*(i+1-bi);
		// print(i, x)
		if(x>ans){
			ans=x;
			t=i;
		}else{
			//break;
		}
	}

	var bx=Math.floor(b/(t+1));
	var aa=[];
	var bb=[];
	var sb=[];
	for(var j=0; j<bx; j++){
		sb.push('x');
	}
	sb=sb.join('');
	for(var j=0, l=t+1-b%(t+1); j<l; j++){
		bb.push(sb);
	}
	for(var j=0, l=b%(t+1); j<l; j++){
		bb.push(sb+'x');
	}
	for(var j=0; j<t-1; j++){
		aa.push('o');
	}
	var sa=[];
	// if(a!==0){

	for(var j=0, l=t===0?a:a-t+1; j<l; j++){
		sa.push('o');
	}
	// }

	sa=sa.join('');
	aa.push(sa);
	aa.push('');
	var ans2=[];
	for(var j=0; j<i; j++){
		ans2.push(bb[j]);
		ans2.push(aa[j]);
	}
	return ans+'\n'+ans2.join('');
}.apply(0, readline().split(' ').map(Number)));

print(function(a, b){
	var ans=[];
	var left=Math.floor(b/2);
	var right=Math.ceil(b/2);
	for(var i=0; i<left; i++){
		ans.push('x');
	}
	for(var i=0; i<a; i++){
		ans.push('o');
	}
	for(var i=0; i<right; i++){
		ans.push('x');
	}

	return (a===0 ? b*b : a*a-left*left-right*right)+'\n'+ans.join('');
}.apply(0, readline().split(' ').map(Number)));

print(function(a, b){
	if(b===0){
		var ans=[];
		for(var i=0; i<a; i++){
			ans.push('o');
		}
		return a*a + '\n' + ans.join('');
	}
	var ans=-1e20;
	var t=-1;
	for(var i=1, l=Math.min(a+1, b); i<=l; i++){
		var bx=Math.floor(b/i);
		var bi=b%i;
		var ai=i<=2 ? 0 : i-1;
		var ax=a-ai;
		var x = ax*ax+ai - (bx+1)*(bx+1)*bi - bx*bx*(i-bi);
		if(x>ans){
			ans=x;
			t=i;
		}else{
			break;
		}
	}

	var bx=Math.floor(b/t);
	var bi=b%t;
	var ai=t<=2 ? 0 : t-1;
	var ax=a-ai;
	var aa=[];
	var bb=[];
	var sb=[];
	for(var i=0; i<bi; i++){
		bb.push(repeat(bx+1, 'x'));
	}
	for(var i=0; i<b-bi; i++){
		bb.push(repeat(bx, 'x'));
	}
	for(var i=0; i<ai; i++){
		aa.push('o');
	}
	aa.push(repeat(ax, 'o'));
	aa.push('');

	var ans2=[];
	for(var i=0; i<t; i++){
		ans2.push(bb[i]);
		ans2.push(aa[i]);
	}
	return ans+'\n'+ans2.join('');
}.apply(0, readline().split(' ').map(Number)));
function repeat(n, c){
	var s='';
	while(n--) s+=c;
	return s;
}

print(function(a, b){
	if(a===0){
		var ans=[];
		for(var i=0; i<b; i++){
			ans.push('x');
		}
		return -b*b + '\n' + ans.join('');
	}
	if(b===0){
		var ans=[];
		for(var i=0; i<a; i++){
			ans.push('o');
		}
		return a*a + '\n' + ans.join('');
	}
	var ans=-1e20;
	var t=-1;
	for(var i=0,l=Math.min(a+1, b); i<l; i++){
		var bx=Math.floor(b/(i+1));
		var bi=b%(i+1);
		var ax=i===0?a:a-i+1;
		var ai=Math.max(0, i-1);
		var x=ax*ax+ai  -  (bx+1)*(bx+1)*bi-bx*bx*(i+1-bi);
		// print(i, x)
		if(x>ans){
			ans=x;
			t=i;
		}else{
			//break;
		}
	}

	var bx=Math.floor(b/(t+1));
	var aa=[];
	var bb=[];
	var sb=[];
	for(var j=0; j<bx; j++){
		sb.push('x');
	}
	sb=sb.join('');
	for(var j=0, l=t+1-b%(t+1); j<l; j++){
		bb.push(sb);
	}
	for(var j=0, l=b%(t+1); j<l; j++){
		bb.push(sb+'x');
	}
	for(var j=0; j<t-1; j++){
		aa.push('o');
	}
	var sa=[];
	// if(a!==0){
	for(var j=0; j<a-t+1; j++){
		sa.push('o');
	}
	// }

	sa=sa.join('');
	aa.push(sa);
	aa.push('');
	var ans2=[];
	for(var j=0; j<i; j++){
		ans2.push(bb[j]);
		ans2.push(aa[j]);
	}
	return ans+'\n'+ans2.join('');
}.apply(0, readline().split(' ').map(Number)));

print(function(a, b){
	if(b===0){
		var ans=[];
		for(var i=0; i<a; i++){
			ans.push('o');
		}
		return a*a + '\n' + ans.join('');
	}
	var ans=-1e20;
	var t=-1;
	for(var i=1, l=Math.min(a+1, b); i<=l; i++){
		var bx=Math.floor(b/i);
		var bi=b%i;
		var ai=i<=2 ? 0 : i-2;
		var ax=a-ai;
		var x = ax*ax+ai - (bx+1)*(bx+1)*bi - bx*bx*(i-bi);
		if(x>ans){
			ans=x;
			t=i;
		}else{
			break;
		}
	}

	var bx=Math.floor(b/t);
	var bi=b%t;
	var ai=t<=2 ? 0 : t-2;
	var ax=a-ai;

	var aa=[];
	var bb=[];
	var sb1=repeat(bx+1, 'x');
	var sb2=repeat(bx, 'x');
	for(var i=0; i<bi; i++){
		bb.push(sb1);
	}
	for(var i=0; i<b-bi; i++){
		bb.push(sb2);
	}
	for(var i=0; i<ai; i++){
		aa.push('o');
	}
	aa.push(repeat(ax, 'o'));
	aa.push('');

	var ans2=[];
	for(var i=0; i<t; i++){
		ans2.push(bb[i]);
		ans2.push(aa[i]);
	}
	return ans+'\n'+ans2.join('');
}.apply(0, readline().split(' ').map(Number)));
function repeat(n, c){
	var s='';
	while(n--) s+=c;
	return s;
}

print(function(a, b){
	var ans=[];
	var left=Math.floor(b/2);
	var right=Math.ceil(b/2);
	for(var i=0; i<left; i++){
		ans.push('x');
	}
	for(var i=0; i<a; i++){
		ans.push('o');
	}
	for(var i=0; i<right; i++){
		ans.push('x');
	}
	return (a*a-left*left-right*right)+'\n'+ans.join('');
}.apply(0, readline().split(' ').map(Number)));

print(function(a, b){
	var ans=[];
	for(var i=0, l=Math.floor(b/2); i<l; i++){
		ans.push('x');
	}
	for(var i=0; i<a; i++){
		ans.push('o');
	}
	for(var i=0, l=Math.ceil(b/2); i<l; i++){
		ans.push('x');
	}
	return ans.join('');
}.apply(0, readline().split(' ').map(Number)));

print(function(a, b){
	if(a===0){
		var ans=[];
		for(var i=0; i<b; i++){
			ans.push('x');
		}
		return -b*b + '\n' + ans.join('');
	}
	if(b===0){
		var ans=[];
		for(var i=0; i<a; i++){
			ans.push('o');
		}
		return a*a + '\n' + ans.join('');
	}
	var ans=-1e20;
	var t=-1;
	for(var i=0,l=Math.min(a+1, b); i<l; i++){
		var bx=Math.floor(b/(i+1));
		var bi=b%(i+1);
		var x=(a-i)*(a-i)+i  -  (bx+1)*(bx+1)*bi-bx*bx*(i+1-bi);
		if(x>ans){
			ans=x;
			t=i;
		}else{
			break;
		}
	}

	var bx=Math.floor(b/(t+1));
	var aa=[];
	var bb=[];
	var sb=[];
	for(var j=0; j<bx; j++){
		sb.push('x');
	}
	sb=sb.join('');
	for(var j=0, l=t+1-b%(t+1); j<l; j++){
		bb.push(sb);
	}
	for(var j=0, l=b%(t+1); j<l; j++){
		bb.push(sb+'x');
	}
	for(var j=0; j<t-1; j++){
		aa.push('o');
	}
	var sa=[];
	// if(a!==0){
	for(var j=0; j<a-t+1; j++){
		sa.push('o');
	}
	// }

	sa=sa.join('');
	aa.push(sa);
	aa.push('');
	var ans2=[];
	for(var j=0; j<i; j++){
		ans2.push(bb[j]);
		ans2.push(aa[j]);
	}
	return ans+'\n'+ans2.join('');
}.apply(0, readline().split(' ').map(Number)));

print(function(a, b){
	var i, l, ans=-1e20, t=-1;

	if(b===0){
		ans=[];
		for(i=0; i<a; i++){
			ans.push('o');
		}
		return a*a + '\n' + ans.join('');
	}

	for(i=1, l=Math.min(a+1, b); i<=l; i++){
		var bx=Math.floor(b/i);
		var bi=b%i;
		var ai=i<=2 ? 0 : i-2;
		var ax=a-ai;
		var x = ax*ax+ai - (bx+1)*(bx+1)*bi - bx*bx*(i-bi);
		if(x>ans){
			ans=x;
			t=i;
		}
	}

	var bx=Math.floor(b/t);
	var bi=b%t;
	var ai=t<=2 ? 0 : t-2;
	var ax=a-ai;
	var sb1=repeat(bx+1, 'x');
	var sb2=repeat(bx, 'x');

	var ans2='';
	for(i=0; i<t; i++){
		ans2+= (i<bi?sb1:sb2)+(i<ai?'0':i===ai?repeat(ax, 'o'):'');
	}
	return ans+'\n'+ans2;
}.apply(0, readline().split(' ').map(Number)));
function repeat(n, c){
	var s='';
	while(n--) s+=c;
	return s;
}

print(function(a, b){
	var ans=[];
	var left=Math.floor(b/2);
	var right=Math.ceil(b/2);
	for(var i=0; i<left; i++){
		ans.push('x');
	}
	for(var i=0; i<a; i++){
		ans.push('o');
	}
	for(var i=0; i<right; i++){
		ans.push('x');
	}

	return (a===0 ? -b*b : a*a-left*left-right*right)+'\n'+ans.join('');
}.apply(0, readline().split(' ').map(Number)));

print(function(a, b){

	var ans=-1e20;
	var t=-1;
	for(var i=0,l=Math.min(a+1, b); i<=l; i++){
		var bx=Math.floor(b/(i+1));
		var bi=b%(i+1);
		var x=(a-i)*(a-i)+i  -  (bx+1)*(bx+1)*bi-bx*bx*(i+1-bi);
		if(x>ans){
			ans=x;
			t=i;
		}else{
			break;
		}
	}

	var bx=Math.floor(b/(t+1));
	var aa=[];
	var bb=[];
	var sb=[];
	for(var j=0; j<bx; j++){
		sb.push('x');
	}
	sb=sb.join('');
	for(var j=0, l=t+1-b%(t+1); j<l; j++){
		bb.push(sb);
	}
	for(var j=0, l=b%(t+1); j<l; j++){
		bb.push(sb+'x');
	}
	for(var j=0; j<t-1; j++){
		aa.push('o');
	}
	var sa=[];
	if(a!==0){
		for(var j=0; j<a-t+1; j++){
			sa.push('o');
		}
	}
	// print(t)
	sa=sa.join('');
	aa.push(sa);
	aa.push('');
	var ans2=[];
	for(var j=0; j<i; j++){
		ans2.push(bb[j]);
		ans2.push(aa[j]);
	}
	return ans+'\n'+ans2.join('');
}.apply(0, readline().split(' ').map(Number)));

print(function(a, b){

	var ans=-1e20;
	var t=-1;
	for(var i=0,l=Math.min(a+1, b); i<l; i++){
		var bx=Math.floor(b/(i+1));
		var bi=b%(i+1);
		var x=(a-i)*(a-i)+i  -  (bx+1)*(bx+1)*bi-bx*bx*(i+1-bi);
		if(x>ans){
			ans=x;
			t=i;
		}else{
			break;
		}
	}

	var bx=Math.floor(b/(t+1));
	var aa=[];
	var bb=[];
	var sb=[];
	for(var j=0; j<bx; j++){
		sb.push('x');
	}
	sb=sb.join('');
	for(var j=0, l=t+1-b%(t+1); j<l; j++){
		bb.push(sb);
	}
	for(var j=0, l=b%(t+1); j<l; j++){
		bb.push(sb+'x');
	}
	for(var j=0; j<t-1; j++){
		aa.push('o');
	}
	var sa=[];
	if(a!==0){
		for(var j=0; j<a-t+1; j++){
			sa.push('o');
		}
	}
	// print(t)
	sa=sa.join('');
	aa.push(sa);
	aa.push('');
	var ans2=[];
	for(var j=0; j<i; j++){
		ans2.push(bb[j]);
		ans2.push(aa[j]);
	}
	return ans+'\n'+ans2.join('');
}.apply(0, readline().split(' ').map(Number)));

print(function(a, b){
	if(b===0){
		var ans=[];
		for(var i=0; i<a; i++){
			ans.push('o');
		}
		return a*a + '\n' + ans.join('');
	}
	var ans=-1e20;
	var t=-1;
	for(var i=1, l=Math.min(a+1, b); i<=l; i++){
		var bx=Math.floor(b/i);
		var bi=b%i;
		var ai=i-1;
		var ax=a-ai;
		var x = ax*ax+ai - (bx+1)*(bx+1)*bi - bx*bx*(i-bi);
		if(x>ans){
			ans=x;
			t=i;
		}else{
			break;
		}
	}

	var bx=Math.floor(b/t);
	var bi=b%t;
	var ai=t-1;
	var ax=a-ai;
	var aa=[];
	var bb=[];
	var sb=[];
	for(var i=0; i<bi; i++){
		bb.push(repeat(bx+1, 'x'));
	}
	for(var i=0; i<b-bi; i++){
		bb.push(repeat(bx, 'x'));
	}
	for(var i=0; i<ai; i++){
		aa.push('o');
	}
	aa.push(repeat(ax, 'o'));
	aa.push('');

	var ans2=[];
	for(var i=0; i<t; i++){
		ans2.push(bb[i]);
		ans2.push(aa[i]);
	}
	return ans+'\n'+ans2.join('');
}.apply(0, readline().split(' ').map(Number)));
function repeat(n, c){
	var s='';
	while(n--) s+=c;
	return s;
}


var e=readline();
for(var i=0;i<e;i++){
  var n=parseInt(readline());
  var r=1;
  while(n>1){
    r=r<<1;
    n=n>>1;
  }
  print(r-1);
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else if(code == 'long'){
			ret[i] = BigInt(next());
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var N = nextInt();
		var tmp = "";
		while(N > 0){
			tmp = N % 2 + tmp;
			N = Math.floor(N / 2);
		}
		var output = Math.pow(2, tmp.length - 1) - 1;
		myout(output);
	}
}

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0];
    for(var j = 1; j <= n; j++){
        var k = lines[j];
        var answer = 0;
        var last = 0;
        while(k > answer){
            last = answer;
            answer = (2 * answer) + 1;
        }
        console.log(last);
    }
});

const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
let input = [];
rl.on('line', line => {
    input.push(line);
})
rl.on('close', line => {
    var t = Number(input[0]);
    l=1;
    for(var i=0;i<t;i++){
        var n = Number(input[l++]);

    var ans=0;
    var res=0;
    var cnt=0;
    while(res<=n){
        ans=res;
        res=Math.pow(2,cnt);
        cnt++;
    }
    console.log(ans-1);
    }

});

var tc=readline();
while(tc--)
{
 var n=readline();n=Number(n);
 var u=Math.log2(n)+1;
 u=Math.floor(u);
 print(Math.pow(2,u-1)-1);
 }

const cases = readline()
var bit = []
for (var i = 0; i < cases; i++) {
    bit[i] = readline()
}
var i = 0
while (i < bit.length) {
    var res = bit[i]
    var last = 0
    for(var j=0; j<30; ++j) {
        if ((res >> j)& 1 === 1) {
            last = j
        }
    }
    print((1<<last)-1)
    i++
}

var t = parseInt(readline());

for (var i = 0; i < t; i++) {
  var n = parseInt(readline());

  while ((n & (n - 1)) > 0) {
    n = n & (n - 1);
  }

  print(n - 1);
}

///////////////////////////////// pre-define ////////////////////////////////////////////////////////////////////////////////
const pr = console.log;
const mi = Math.min;
const mx = Math.max;
const abs = Math.abs;
const fl = Math.floor;
const ce = Math.ceil;
const sq = Math.sqrt;
const lge = Math.log;
const lg10 = Math.log10;
const gcd = (a, b) => b == 0 ? a : gcd(b, a % b);
const lcm = (a, b) => (a / gcd(a, b)) * b;
const amax = (a) => mx.apply(Math, a);
const amin = (a) => mi.apply(Math, a);
const sm = (a) => a.reduce(((x, y) => x + y), 0);
const aeq = (a, b) => JSON.stringify(a) == JSON.stringify(b);
const swap = (a, i, j) => [a[i], a[j]] = [a[j], a[i]];
const stin = (a) => a.sort((x, y) => x - y);
const stde = (a) => a.sort((x, y) => y - x);
const counter = (a_or_s) => { let map = new Map(); for (const i of a_or_s) map.set(i, map.get(i) + 1 || 1); return map; };
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

let d = [1, 0];
const solve = () => {
    for (let i = 2; 2 ** i <= 536870912; i++) {
        d.unshift(2 ** i - 1);
    }
    // pr(d);
};

const go = (x) => {
    let n = d.length;
    for (let i = 0; i < n; i++) {
        if (x > d[i]) return pr(d[i]);
    }
};

const main = () => {
    const readline = require('readline');
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });
    let input = [];
    rl.on('line', (line) => {
        input.push(Number(line));
    });
    rl.on('close', () => {
        solve();
        let t = input[0];
        let i = 1;
        while (t--) {
            go(input[i]);
            i++;
        }
    });
};

main()

let data = '';
process.stdin.on('data', c => data += c);

function* nextLine() {
	let lines = data.trim().split(/\n/g);
	for(let l of lines){
		yield l.trim();
	}
}

let nl = nextLine();

nl.elem = function(funParse) {
		return funParse(this.next().value);
	};

nl.array = function(funParse) {
		return this.next().value.split(/\s/g).map(funParse||(x => x));
	};

nl.num = function() {
		return nl.elem(Number);
	};

nl.nums = function() {
		return nl.array(Number);
	};

nl.line = function() {
		return this.next().value;
	};

const sol = () => {
	let t = nl.num();
    let list = [];
    for (let i = 0; i < t; i++){
        list.push(nl.num());
    }
    let bitSize = (n) => {
        let cnt = 0;
        while(n > 1) {
            n >>= 1;
            cnt++;
        }
        return cnt;
    }
    let bitMax = (n) => {
        let max = 1;
        for(let i = 0; i < n; i++){
            max <<= 1;
        }
        return max - 1;
    }

	console.log(list.map(bitSize).map(bitMax).join('\n'));

};

process.stdin.on('end', sol);

let data = '';
process.stdin.on('data', c => data += c);

function* nextLine() {
	let lines = data.trim().split(/\n/g);
	for(let l of lines){
		yield l.trim();
	}
}

let nl = nextLine();

nl.elem = function(funParse) {
		return funParse(this.next().value);
	};

nl.array = function(funParse) {
		return this.next().value.split(/\s/g).map(funParse||(x => x));
	};

nl.num = function() {
		return nl.elem(Number);
	};

nl.nums = function() {
		return nl.array(Number);
	};

nl.line = function() {
		return this.next().value;
	};

const sol = () => {
	let t = nl.num();
    let bitSize = (n) => {
        let cnt = 0;
        while(n > 1) {
            n >>= 1;
            cnt++;
        }
        return cnt;
    }
    let bitMax = (n) => {
        let max = 1;
        for(let i = 0; i < n; i++){
            max <<= 1;
        }
        return max - 1;
    }
    let ans = [];
    for(let i = 0; i < t; i++) {
        let n = nl.num();
        ans.push(bitMax(bitSize(n)));
    }
	console.log(ans.join('\n'));

};

process.stdin.on('end', sol);

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
function readLine() {
    return inputString[currentLine++];
};
process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    main();
    // cmd(not powershell): node cp.js < input.txt
});

function main() {
    let t = parseInt(readLine());
    while (t-- > 0) {
        console.log(solve());
    }
}
function solve() {
    let n = parseInt(readLine()), last = 0;
    for (let i = 0; i < 30; ++i) {
        if (((n >> i) & 1) == 1) {
            last = i;
        }
    }
    return (1 << last) - 1;
}

var readline = require('readline');

var rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});
var lines = [];
rl.on('line', function(input) {
    lines.push(input);
});
rl.on('close', function() {
    var t = parseInt(lines[0]);
    var l = 1;
    for (var i = 0; i < t; i++) {
        var n = +lines[l++]
        console.log(solve(n));
    }
});

function solve(n) {
	const base = Math.floor(Math.log2(n))
	return Math.pow(2, base) - 1
}

'use-strict'

process.stdin.resume();
process.stdin.setEncoding('utf8');

let data = '';
let currentLine = 0;

process.stdin.on('data', chunk => {
data += chunk;
});

process.stdin.on('end', () =>{
    data = data.replace(/\s*$/, '')
    .split('\n')
    .map(str => str.replace(/\s*$/, ''));

        let testCases = parseInt(readLine());
        while(testCases--)
            print(Math.pow(2,parseInt(Math.log(parseInt(readLine())) / Math.log(2), 10)) - 1)

});

function print(c){
    return console.log(c);
}

function get_ints() {
    return readLine().split(' ').map(Number)
}

function readLine() {
        return data[currentLine++];
}

///////////////////////////////// pre-define ////////////////////////////////////////////////////////////////////////////////
const pr = console.log;
const mi = Math.min;
const mx = Math.max;
const abs = Math.abs;
const fl = Math.floor;
const ce = Math.ceil;
const sq = Math.sqrt;
const lge = Math.log;
const lg10 = Math.log10;
const gcd = (a, b) => b == 0 ? a : gcd(b, a % b);
const lcm = (a, b) => (a / gcd(a, b)) * b;
const amax = (a) => mx.apply(Math, a);
const amin = (a) => mi.apply(Math, a);
const sm = (a) => a.reduce(((x, y) => x + y), 0);
const aeq = (a, b) => JSON.stringify(a) == JSON.stringify(b);
const swap = (a, i, j) => [a[i], a[j]] = [a[j], a[i]];
const stin = (a) => a.sort((x, y) => x - y);
const stde = (a) => a.sort((x, y) => y - x);
const counter = (a_or_s) => { let map = new Map(); for (const i of a_or_s) map.set(i, map.get(i) + 1 || 1); return map; };
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

const solve = (n) => {
    if (n == 1) return pr(0);
    pr(n & 1 ? n - 2 : n - 1)
};

const main = () => {
    const readline = require('readline');
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });
    let input = [];
    rl.on('line', (line) => {
        input.push(Number(line));
    });
    rl.on('close', () => {
        let t = input[0];
        let i = 1;
        while (t--) {
            solve(input[i]);
            i++;
        }
    });
};

main()

///////////////////////////////// pre-define ////////////////////////////////////////////////////////////////////////////////
const pr = console.log;
const mi = Math.min;
const mx = Math.max;
const abs = Math.abs;
const fl = Math.floor;
const ce = Math.ceil;
const sq = Math.sqrt;
const lge = Math.log;
const lg10 = Math.log10;
const gcd = (a, b) => b == 0 ? a : gcd(b, a % b);
const lcm = (a, b) => (a / gcd(a, b)) * b;
const amax = (a) => mx.apply(Math, a);
const amin = (a) => mi.apply(Math, a);
const sm = (a) => a.reduce(((x, y) => x + y), 0);
const aeq = (a, b) => JSON.stringify(a) == JSON.stringify(b);
const swap = (a, i, j) => [a[i], a[j]] = [a[j], a[i]];
const stin = (a) => a.sort((x, y) => x - y);
const stde = (a) => a.sort((x, y) => y - x);
const counter = (a_or_s) => { let map = new Map(); for (const i of a_or_s) map.set(i, map.get(i) + 1 || 1); return map; };
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

const solve = (n) => {
    pr(n & 1 ? n - 2 : n - 1)
};

const main = () => {
    const readline = require('readline');
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });
    let input = [];
    rl.on('line', (line) => {
        input.push(Number(line));
    });
    rl.on('close', () => {
        let t = input[0];
        let i = 1;
        while (t--) {
            solve(input[i]);
            i++;
        }
    });
};

main()

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
function readLine() {
    return inputString[currentLine++];
};
process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    main();
    // cmd(not powershell): node cp.js < input.txt
});

function main() {
    let t = parseInt(readLine());
    while (t-- > 0) {
        console.log(solve());
    }
}
function solve() {
    let num = temp = parseInt(readLine());
    for (let i = 1; i <= temp; i++) {
        num = num & (num - i);
        if (num === 0) {
            return temp-i;
        }
    }
}

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0];
    for(var j = 1; j <= n; j++){
        var k = lines[j];
        //console.log(2 + ' ' + (k - 1));
    }
    console.log(1 + "\n" + 3 + "\n" + 15)
});

var readline = require('readline');

var rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});
var lines = [];
rl.on('line', function(input) {
    lines.push(input);
});
rl.on('close', function() {
    var t = parseInt(lines[0]);
    var l = 1;
    for (var i = 0; i < t; i++) {
        var n = +lines[l++]
        console.log('Case #%d: %s', i + 1, solve(n));
    }
});

function solve(n) {
	const base = Math.floor(Math.log2(n))
	return Math.pow(2, base) - 1
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else if(code == 'long'){
			ret[i] = BigInt(next());
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var N = nextInt();
		var tmp = "";
		while(N > 0){
			tmp = N % 2 + tmp;
			N = Math.floor(N / 2);
		}
		//myerr(tmp);
		var ok = "";
		var isOK = true;
		for(var i = 0; i < tmp.length; i++){
			if(!isOK){
				ok += "1";
				continue;
			}
			if(tmp[i] == "1"){
				ok += "0";
			}else{
				ok += "1";
				isOK = false;
			}
		}
		var output = parseInt(ok, 2);
		myout(output);
	}
}

var tc=readline();
while(tc--)
{
 var n=readline();n=Number(n);
  var ans;
  for(var i=0;i<32;i++)
  {
      var u=Math.pow(2,i);
    if(u-1<=n)
       ans=u-1;
    else break;
  }
   if(n==1) print(0);
 else print(ans);
}

var tc=readline();
while(tc--)
{
 var n=readline();n=Number(n);
  var ans;
  for(var i=0;i<32;i++)
  {
      var u=Math.pow(2,i);
    if(u-1<=n)
       ans=u-1;
    else break;
  }
  print(ans);
}

var tc=readline();
while(tc--)
{
 var n=readline();
  var a=n;var k=0;
  while(n)
{
      n=(n&(a-1));
      k++;
     a--;
    if(n==0)
    {
     print(k);
    break;
    }

}
}


function ansb(n,k,str){

  const obj = {}

  for(var i = 0 ; i < str.length ; i++){

    var cnt = 1;
    while(str[i+1] === str[i] && i+1 !== str.length){
      cnt++;
      i++
      // console.log("here")
      // console.log(cnt)
    }
    if(cnt >= k)obj[str[i]] ? obj[str[i]] += Math.floor(cnt/k) : obj[str[i]] = Math.floor(cnt/k);
  }
  var arr = Object.keys(obj).map(function(key){ return obj[key]});
  var max = Math.max(...arr);
  print(max === -Infinity ? 0 : max);
}

var line = readline().split(' ')
var str = readline()
ansb(parseInt(line[0]),parseInt(line[1]),str);

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let l = 0;
let x = 0
let k = 0
let n = 0
rl.on('line', (input) => {
    if (l === 0) {
        let arr = input.split(" ").map(x => parseInt(x))
        x = arr[0]
        k = arr[1]
    } else {
        rl.close();
        let hm = {}
        let arr = input.split("")
        let c = 0
        for (let i = 0; i < arr.length; i++) {
            let cnt = 1
            let st = i
            while (i + 1 < arr.length && arr[i] === arr[i + 1] && cnt < k) {
                cnt++
                i++
            }
            if (hm[arr[i]] && cnt === k) {
                hm[arr[i]]++
            } else if (cnt === k) {
                hm[arr[i]] = 1
            }
        }

        let mn = 0
        for (let e in hm) {
            if (mn < hm[e]) {
                mn = hm[e]
            }
        }
        console.log(mn)
        return
    }
    l++
})

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let l = 0;
let x = 0
let k = 0
let n = 0
rl.on('line', (input) => {
    if (l === 0) {
        let arr = input.split(" ").map(x => parseInt(x))
        x = arr[0]
        k = arr[1]
    } else {
        rl.close();
        let hm = {}
        let arr = input.split("")
        let c = 0
        for (let i = 0; i < arr.length - 1; i++) {
            let cnt = 1
            let st = i
            while (arr[i] === arr[i + 1] && cnt < k) {
                cnt++
                i++
            }
            if (hm[arr[i]] && cnt === k) {
                hm[arr[i]]++
            } else if (cnt === k) {
                hm[arr[i]] = 1
            }
        }

        let mn = 0
        for (let e in hm) {
            if (mn < hm[e]) {
                mn = hm[e]
            }
        }
        if (mn === 0 && k === 1) {
            console.log(1)
            return
        }
        console.log(mn)
        return
    }
    l++
})

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let l = 0;
let x = 0
let k = 0
let n = 0
rl.on('line', (input) => {
    if (l === 0) {
        let arr = input.split(" ").map(x => parseInt(x))
        x = arr[0]
        k = arr[1]
    } else {
        rl.close();
        let hm = {}
        let arr = input.split("")
        let c = 0
        for (let i = 0; i < arr.length - 1; i++) {
            let cnt = 1
            let st = i
            while (arr[i] === arr[i + 1] && cnt < k) {
                cnt++
                i++
            }
            if (hm[arr[i]] && cnt == k) {
                hm[arr[i]]++
            } else if (cnt === k) {
                hm[arr[i]] = 1
            }
        }
        let mn = 0
        for (let e in hm) {
            if (mn < hm[e]) {
                mn = hm[e]
            }
        }
        console.log(mn)
        return
    }
    l++
})

function ansb(n,k,str){

  var obj = {}

  for(var i = 0 ; i < str.length ; i++){

    var cnt = 1;
    while(str[i+1] === str[i] && i+1 !== str.length){
      cnt++;
      i++
      // console.log("here")
      // console.log(cnt)
    }
    if(cnt >= k)obj[str[i]] ? obj[str[i]] += Math.floor(cnt/k) : obj[str[i]] = Math.floor(cnt/k);
  }
  var arr = Object.values(obj);
  var max = Math.max(...arr);
  console.log(max === -Infinity ? 0 : max);
}

var input = readline().split(',');
print(input[1])

function ansb(n,k,str){

  var obj = {}

  for(var i = 0 ; i < str.length ; i++){

    var cnt = 1;
    while(str[i+1] === str[i] && i+1 !== str.length){
      cnt++;
      i++
      // console.log("here")
      // console.log(cnt)
    }
    if(cnt >= k)obj[str[i]] ? obj[str[i]] += Math.floor(cnt/k) : obj[str[i]] = Math.floor(cnt/k);
  }
  var arr = Object.values(obj);
  var max = Math.max(...arr);
  console.log(max === -Infinity ? 0 : max);
}

var input = readline().split(' ');
print(input)

function ansb(n,k,str){

  var obj = {}

  for(var i = 0 ; i < str.length ; i++){

    var cnt = 1;
    while(str[i+1] === str[i] && i+1 !== str.length){
      cnt++;
      i++
      // console.log("here")
      // console.log(cnt)
    }
    if(cnt >= k)obj[str[i]] ? obj[str[i]] += Math.floor(cnt/k) : obj[str[i]] = Math.floor(cnt/k);
  }
  var arr = Object.values(obj);
  var max = Math.max(...arr);
  console.log(max === -Infinity ? 0 : max);
}

var input = readline().split('/n');
print(input[1])

function ansb(n,k,str){

  var obj = {}

  for(var i = 0 ; i < str.length ; i++){

    var cnt = 1;
    while(str[i+1] === str[i] && i+1 !== str.length){
      cnt++;
      i++
      // console.log("here")
      // console.log(cnt)
    }
    if(cnt >= k)obj[str[i]] ? obj[str[i]] += Math.floor(cnt/k) : obj[str[i]] = Math.floor(cnt/k);
  }
  var arr = Object.values(obj);
  var max = Math.max(...arr);
  console.log(max === -Infinity ? 0 : max);
}

var line = readline().split(' ')
print(parseInt(line[0]) + parseInt(line[1]))

function ansb(n,k,str){

  var obj = []

  for(var i = 0 ; i < str.length ; i++){

    var cnt = 1;
    while(str[i+1] === str[i] && i+1 !== str.length){
      cnt++;
      i++
      // console.log("here")
      // console.log(cnt)
    }
    if(cnt >= k)obj[str[i]] ? obj[str[i]] += Math.floor(cnt/k) : obj[str[i]] = Math.floor(cnt/k);
  }
  var max = Math.max(...obj);
  print(max === -Infinity ? 0 : max);
}

var line = readline().split(' ')
var str = readline()
ansb(parseInt(line[0]),parseInt(line[1]),str);

function ansb(n,k,str){

  const obj = []

  for(var i = 0 ; i < str.length ; i++){

    var cnt = 1;
    while(str[i+1] === str[i] && i+1 !== str.length){
      cnt++;
      i++
      // console.log("here")
      // console.log(cnt)
    }
    if(cnt >= k)obj[str[i]] ? obj[str[i]] += Math.floor(cnt/k) : obj[str[i]] = Math.floor(cnt/k);
  }
  var max = Math.max(...obj);
  print(max === -Infinity ? 0 : max);
}

var line = readline().split(' ')
var str = readline()
ansb(parseInt(line[0]),parseInt(line[1]),str);

function ansb(n,k,str){

  var obj = {}

  for(var i = 0 ; i < str.length ; i++){

    var cnt = 1;
    while(str[i+1] === str[i] && i+1 !== str.length){
      cnt++;
      i++
      // console.log("here")
      // console.log(cnt)
    }
    if(cnt >= k)obj[str[i]] ? obj[str[i]] += Math.floor(cnt/k) : obj[str[i]] = Math.floor(cnt/k);
  }
  var arr = Object.values(obj);
  var max = Math.max(...arr);
  console.log(max === -Infinity ? 0 : max);
}

var input = readline().split(',');
print(input[0])

function ansb(n,k,str){

  var obj = {}

  for(var i = 0 ; i < str.length ; i++){

    var cnt = 1;
    while(str[i+1] === str[i] && i+1 !== str.length){
      cnt++;
      i++
      // console.log("here")
      // console.log(cnt)
    }
    if(cnt >= k)obj[str[i]] ? obj[str[i]] += Math.floor(cnt/k) : obj[str[i]] = Math.floor(cnt/k);
  }
  var arr = Object.values(obj);
  var max = Math.max(...arr);
  console.log(max === -Infinity ? 0 : max);
}

var line = readline().split(' ')
var line2 = readline()
print(parseInt(line[0]) + parseInt(line[1]))
print(line2)

function ansb(n,k,str){

  var obj = {}

  for(var i = 0 ; i < str.length ; i++){

    var cnt = 1;
    while(str[i+1] === str[i] && i+1 !== str.length){
      cnt++;
      i++
      // console.log("here")
      // console.log(cnt)
    }
    if(cnt >= k)obj[str[i]] ? obj[str[i]] += Math.floor(cnt/k) : obj[str[i]] = Math.floor(cnt/k);
  }
  var arr = Object.values(obj);
  var max = Math.max(...arr);
  console.log(max === -Infinity ? 0 : max);
}

var input = readline().split('/n');
print(input)