#include using namespace std; using ll = long long; #ifdef LOCAL #include #else #define debug(...) #endif void solve() { int N; cin >> N; // popcount(N) = 1 の場合, No if (__builtin_popcount(N) == 1) { cout << "No" << "\n"; return; } // 右から 2 個目の 1 の位置を求める int ctz = __builtin_ctz(N), ctz2 = 30; for (int i = ctz + 1; i < 30; i++) { if (N & (1 << i)) { ctz2 = i; break; } } int N2 = N - (1 << ctz) - (1 << ctz2); for (int i = ctz2 + 1; i < 30; i++) { int M = N2 + (1 << i); if (__builtin_popcount(M) < __builtin_popcount(N)) { cout << M - N << "\n"; return; } } } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); int T; cin >> T; while (T--) solve(); }