#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  long long n;
  while (t--) {
    cin >> n;
    if (n % 4 == 1) {
      cout << 2 * n + 1;
    } else if (n % 4 == 2) {
      cout << 4 * n + 1;
    } else if (n % 4 == 3) {
      cout << n + 1;
    } else
      cout << 4 * n + 1;
    cout << endl;
  }
  return 0;
}
