#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, n;
  cin >> t;
  while (t--) {
    cin >> n;
    cout << (4 * n) / gcd(n + 1, 4 * n) + 1 << endl;
  }
  return 0;
}
