#include <bits/stdc++.h>
using namespace std;
int main() {
  int T, n;
  long long ans;
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &n);
    if (n % 2 == 0)
      ans = n * 4LL + 1LL;
    else if (n % 4 == 1)
      ans = 3LL + (n / 4LL) * 8LL;
    else
      ans = n + 1LL;
    cout << ans << endl;
  }
  return 0;
}
