#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b;
  int t;
  cin >> t;
  while (t--) {
    cin >> a;
    if (a % 2 == 0)
      cout << a * 4 + 1 << endl;
    else {
      switch ((a + 1) % 4) {
        case 0:
          cout << a + 1 << endl;
          break;
        case 1:
        case 3:
          cout << a * 4 + 1 << endl;
          break;
        case 2:
          cout << a * 2 + 1 << endl;
          break;
      }
    }
  }
  return 0;
}
