#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  if (b == 0) return a;
  return a >= b ? gcd(b, a % b) : gcd(a, b % a);
}
int main() {
  int test;
  long long n;
  for (scanf("%d", &test); test--;) {
    cin >> n;
    cout << 4 * n / gcd(4 * n, n + 1) + 1 << endl;
  }
  return 0;
}
