#include using namespace std; using Int = int64_t; using uInt = uint64_t; template using min_heap = priority_queue, greater>; template using max_heap = priority_queue, less>; void solve( /* Copyright by Urtusea */ ) { int n; cin >> n; int now = 1, cnt = 1; while (now < n) { now += __popcount(now); cnt += 1; } if (now == n) { cout << cnt << '\n'; } else { cout << -1 << '\n'; } } int main(int argc, char *argv[], char *envp[]) { cin.tie(nullptr)->sync_with_stdio(false); // for (int i = 1, n = (cin >> n, n); i <= n; i++) solve(); return 0; }