#include <bits/stdc++.h>
using namespace std;
long long n, t, i, m;
int main() {
  cin >> t;
  for (i = 0; i < t; i++) {
    scanf("%I64d", &n);
    long long temp = (n * (n + 1)) % (4 * n);
    if (temp == 0)
      printf("%I64d\n", n + 1);
    else {
      temp /= n;
      m = temp % 4;
      if (m == 2)
        printf("%I64d\n", 2 * n + 1);
      else
        printf("%I64d\n", 4 * n + 1);
    }
  }
  return 0;
}
