#include <bits/stdc++.h>
using namespace std;
long long t, x, st;
int main() {
  cin >> t;
  for (int i = 1; i <= t; i++) {
    cin >> x;
    if (x % 4 == 0) cout << 4 * x + 1 << endl;
    if (x % 4 == 1) cout << 2 * x + 1 << endl;
    if (x % 4 == 2) cout << 4 * x + 1 << endl;
    if (x % 4 == 3) cout << x + 1 << endl;
  }
  return 0;
}
