#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[], char *envp[]) {
  long long testcnt, tmp;
  cin >> testcnt;
  while (testcnt--) {
    cin >> tmp;
    switch (tmp % 4) {
      case 1:
        cout << 2 * tmp + 1;
        break;
      case 3:
        cout << tmp + 1;
        break;
      default:
        cout << 4 * tmp + 1;
    }
    cout << '\n';
  }
  return 0;
}
