#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
int main() {
  int cas;
  scanf("%d", &cas);
  for (int cc = 1; cc <= cas; cc++) {
    long long s;
    cin >> s;
    cout << (s * 4) / gcd(s * 4, s + 1) + 1 << endl;
  }
  return 0;
}
