#include <bits/stdc++.h>
unsigned gcd(unsigned a, unsigned b) {
  while (a && b)
    if (a < b)
      b %= a;
    else
      a %= b;
  return a + b;
}
int main(void) {
  int i, t, n;
  scanf("%d", &t);
  for (i = 0; i < t; ++i) {
    scanf("%d", &n);
    printf("%u\n", 1 + 4 * n / gcd(4 * n, n + 1));
  }
  exit(EXIT_SUCCESS);
}
