#include <bits/stdc++.h>
using namespace std;
int scan() {
  int t = 0;
  char c;
  c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') {
    t = (t << 3) + (t << 1) + c - '0';
    c = getchar();
  }
  return (t);
}
int main() {
  int t, n2, rem;
  long long int n;
  t = scan();
  while (t--) {
    n2 = scan();
    n = n2;
    if (n == 1) {
      printf("3\n");
      continue;
    }
    rem = (n + 1) % 4;
    if (rem == 0) printf("%I64d\n", n + 1);
    if (rem == 1 || rem == 3) printf("%I64d\n", 4 * n + 1);
    if (rem == 2) printf("%I64d\n", 2 * n + 1);
  }
  return (0);
}
