#include using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); int t; cin >> t; while (t--) { int n; cin >> n; if (popcount(ull(n)) == 1) { cout << -1 << '\n'; } else { int x = 0; for (int i = 0; i < 30; ++i) { if (n & (1 << i)) { if (x == 0) { x = -(1 << i); } else { x += (1 << i); break; } } } cout << x << '\n'; } } return 0; }