#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, p = 0, cnt;
  cin >> n;
  int* arr = new int[n];
  cnt = p = n;
  n = 0;
  while (p--) {
    cin >> k;
    arr[n++] = k;
  }
  k = 0;
  while (cnt--) {
    if (arr[k] == 2)
      arr[k] = 2;
    else if (arr[k] % 2 != 0)
      arr[k] = 1;
    else if (arr[k] % 2 == 0)
      arr[k] = 0;
    k++;
  }
  for (int i = 0; i < k; i++) {
    cout << arr[i] << ' ';
  }
}
