#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a == 0)
    return b;
  else {
    return gcd(b % a, a);
  }
}
int main() {
  long long t;
  cin >> t;
  for (long long i = 0; i < t; ++i) {
    long long n;
    cin >> n;
    cout << (4 * n) / gcd(n + 1, 4 * n) + 1 << endl;
  }
}
