#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  long long ans = 1;
  for (long long i = 1; i <= b; i++) {
    ans *= a;
  }
  return ans;
}
long long make(string p) {
  long long sum = 0, ck = 1;
  for (long long i = p.size() - 1; i >= 0; i--) {
    sum += (p[i] - '0') * ck;
    ck *= 10;
  }
  return sum;
}
struct Point {
  long long x, y, z;
} point[10000];
int main() {
  ios_base::sync_with_stdio(false);
  long long n;
  cin >> n;
  for (long long ia = 1; ia <= n; ia++) {
    long long x;
    cin >> x;
    long long p;
    if (x % 4 == 0 || x % 4 == 2)
      p = (x * 4) + 1;
    else if (x % 4 == 1)
      p = x * 2 + 1;
    else
      p = x + 1;
    cout << p << endl;
  }
}
