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