#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  cin >> T;
  while (T--) {
    long long n, side = 0, ans = 0;
    cin >> n;
    int i = (n + 1) % 4;
    if (i == 0)
      ans = n + 1;
    else if (i == 1 || i == 3)
      ans = 4 * n + 1;
    else
      ans = 2 * n + 1;
    cout << ans << "\n";
  }
  return 0;
}
