I’m strolling on sunshine, yeah-ah! And doesn’t it feel good! Well, it certainly feels good for our Heroes of Making Magic, who are casually walking on a one-directional road, fighting imps. Imps are weak and feeble creatures and they are not good at much. However, Heroes enjoy fighting them. For fun, if nothing else. 

Our Hero, Ignatius, simply adores imps. He is observing a line of imps, represented as a zero-indexed array of integers a of length n, where ai denotes the number of imps at the i-th position. Sometimes, imps can appear out of nowhere. When heroes fight imps, they select a segment of the line, start at one end of the segment, and finish on the other end, without ever exiting the segment. They can move exactly one cell left or right from their current position and when they do so, they defeat one imp on the cell that they moved to, so, the number of imps on that cell decreases by one. This also applies when heroes appear at one end of the segment, at the beginning of their walk. 

Their goal is to defeat all imps on the segment, without ever moving to an empty cell in it (without imps), since they would get bored. Since Ignatius loves imps, he doesn’t really want to fight them, so no imps are harmed during the events of this task. However, he would like you to tell him whether it would be possible for him to clear a certain segment of imps in the above mentioned way if he wanted to. 

You are given q queries, which have two types: 

  * 1 a b k — denotes that k imps appear at each cell from the interval [a, b]
  * 2 a b - asks whether Ignatius could defeat all imps on the interval [a, b] in the way described above 

Input

The first line contains a single integer n (1 ≤ n ≤ 200 000), the length of the array a. The following line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 5 000), the initial number of imps in each cell. The third line contains a single integer q (1 ≤ q ≤ 300 000), the number of queries. The remaining q lines contain one query each. Each query is provided by integers a, b and, possibly, k (0 ≤ a ≤ b < n, 0 ≤ k ≤ 5 000).

Output

For each second type of query output 1 if it is possible to clear the segment, and 0 if it is not.

Example

Input

3
2 2 2
3
2 0 2
1 1 1 1
2 0 2


Output

0
1

Note

For the first query, one can easily check that it is indeed impossible to get from the first to the last cell while clearing everything. After we add 1 to the second position, we can clear the segment, for example by moving in the following way: <image>.
#include <bits/stdc++.h>
using namespace std;
long long oo = 2e15;
const int maxn = 4e5, maxm = 1e6;
long long z0[maxm], z1[maxm], m0[maxm], m1[maxm];
int c[maxn];
int L, R, x, n, i, q;
void update(int o) {
  m0[o] = min(z0[2 * o] + m0[2 * o], z0[2 * o + 1] + m0[2 * o + 1]);
  m1[o] = min(z1[2 * o] + m1[2 * o], z1[2 * o + 1] + m1[2 * o + 1]);
}
void pushdown(int o) {
  z0[2 * o] += z0[o];
  z0[2 * o + 1] += z0[o];
  z0[o] = 0;
  z1[2 * o] += z1[o];
  z1[2 * o + 1] += z1[o];
  z1[o] = 0;
}
void build(int o, int l, int r) {
  if (l + 1 == r) {
    m0[o] = m1[o] = oo;
    if (l & 1) {
      m1[o] = c[l] - x;
      x = m1[o];
    } else {
      m0[o] = c[l] - x;
      x = m0[o];
    }
    return;
  }
  int m = (l + r) >> 1;
  build(2 * o, l, m);
  build(2 * o + 1, m, r);
  update(o);
}
void change(int o, int l, int r, int x, int y, long long u, long long v) {
  if (x <= l && r <= y) {
    z0[o] += u;
    z1[o] += v;
    return;
  }
  pushdown(o);
  int m = (l + r) >> 1;
  if (x < m) change(2 * o, l, m, x, y, u, v);
  if (m < y) change(2 * o + 1, m, r, x, y, u, v);
  update(o);
}
long long find(int o, int l, int r, int v) {
  if (l + 1 == r) {
    if (l & 1)
      return m1[o] + z1[o];
    else
      return m0[o] + z0[o];
  }
  pushdown(o);
  int m = (l + r) >> 1;
  long long re;
  if (v < m)
    re = find(2 * o, l, m, v);
  else
    re = find(2 * o + 1, m, r, v);
  update(o);
  return re;
}
void find(int o, int l, int r, int x, int y, long long &M0, long long &M1) {
  if (x <= l && r <= y) {
    M0 = min(M0, m0[o] + z0[o]);
    M1 = min(M1, m1[o] + z1[o]);
    return;
  }
  pushdown(o);
  int m = (l + r) >> 1;
  if (x < m) find(2 * o, l, m, x, y, M0, M1);
  if (m < y) find(2 * o + 1, m, r, x, y, M0, M1);
  update(o);
}
void modify(int x, int y, int z) {
  int u = 0, v = 0, len = y - x + 1;
  if (x & 1)
    u = 0, v = z;
  else
    u = z, v = 0;
  change(1, L, R, x, y + 1, u, v);
  if (len & 1) {
    if (y & 1) {
      u = -z;
      v = z;
    } else {
      u = z;
      v = -z;
    }
    if (y + 1 < n) change(1, L, R, y + 1, n, u, v);
  }
}
int ask(int x, int y) {
  int C = 0, p;
  p = (y - x) % 2 ? -1 : 1;
  if (x) C = find(1, L, R, x - 1);
  long long M0 = oo, M1 = oo;
  find(1, L, R, x, y + 1, M0, M1);
  if (x & 1) swap(M0, M1);
  if (M1 - C < 0) return 0;
  if (M0 + C < 1) return 0;
  long long D = find(1, L, R, y) + p * C;
  return D == (y - x + 1) % 2;
}
int main() {
  scanf("%d", &n);
  L = 0, R = n;
  for (i = 0; i < n; i++) scanf("%d", &c[i]);
  x = 0;
  build(1, 0, n);
  scanf("%d", &q);
  for (int qq = 1; qq <= q; qq++) {
    int opt, x, y, z;
    scanf("%d", &opt);
    if (opt == 1) {
      scanf("%d%d%d", &x, &y, &z);
      modify(x, y, z);
    } else {
      scanf("%d%d", &x, &y);
      int ans = ask(x, y);
      printf("%d\n", ans);
    }
  }
  return 0;
}
