#include <bits/stdc++.h>
using namespace std;
int t;
long long temp;
int main() {
  scanf("%d", &t);
  for (int i = 0; i < t; i++) {
    scanf("%I64d", &temp);
    long long jawaban = 0;
    if (temp % 4 == 0) jawaban = (temp * 4) + 1;
    if (temp % 4 == 1) jawaban = (temp * 2) + 1;
    if (temp % 4 == 2) jawaban = (temp * 4) + 1;
    if (temp % 4 == 3) jawaban = temp + 1;
    printf("%I64d\n", jawaban);
  }
  return 0;
}
