#include <stdio.h>
#include <stdlib.h>

int main(){
	int t;
	scanf("%d",&t);

	while(t--){
		long long int a,b = 2;
		scanf("%lld",&a);

		if(a == 1){
			printf("0\n");
			continue;
		}

		while(a > b-1){
			b = b*2;
		}


		printf("%lld\n",b/2-1);
	}
}