#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    long long x;
    for (int i = 0; i < n; i++) {
      cin >> x;
      if (x & 1) {
        if ((x - 1) % 4 == 0)
          cout << x * 2 + 1 << endl;
        else
          cout << x + 1 << endl;
      } else {
        cout << x * 4 + 1 << endl;
      }
    }
  }
}
