#include <iostream>

using namespace std;

int countBits(int n)
{
    int count = 0;
    while (n != 0)
    {
        count++;
        int rmsb = n & -n;
        n &= (~rmsb);
    }

    return count;
}

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        while (countBits(n) != 1)
        {
            n = n & (n - 1);
        }
        cout << n - 1 << endl;
    }
}