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