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