Process with Constant Sum

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

Suppose we have an array aa whose elements are non-negative integers. We can apply operations of two types to this array:

  1. a_ia_i2a\_{i} \gets a\_{i} - 2, a_i+1a_i+1+2a\_{i+1} \gets a\_{i+1} + 2.
  2. If a_i+1=0a\_{i+1} = 0: a_ia_i1a\_{i} \gets a\_{i} - 1, a_i+2a_i+2+1a\_{i+2} \gets a\_{i+2} + 1.

After any operation, all the elements must remain non-negative.

It is easy to see that we cannot do such operations indefinitely. We'll call a chain of operations maximal if no valid operation can occur after performing this chain of operations.

Now you are given an array bb of length nn. Your should handle two types of queries:

  • "1 pp xx" --- assignment b_pxb\_{p} \gets x.
  • "2 ll rr" --- let us treat the subsegment b\[l..r]b\[l..r] as array aa. You have to find the maximum number of zeroes which can be in that array after applying some maximal chain of operations. Note that we don't really change the array bb during this query.

입력

The first line of input contains one integer nn, the length of array bb (1n21051 \le n \le 2 \cdot 10^{5}).

The second line contains nn integers separated by spaces: the initial elements of array bb (0b_i1050 \le b\_{i} \le 10^{5}).

The third line contains one integer qq, the number of queries (1q21051 \le q \le 2 \cdot 10^{5}).

Each of the next qq lines contains a query.

For queries of the first type, 1pn1 \le p \le n and 0x1050 \le x \le 10^{5}.

For queries of the second type, 1lrn1 \le l \le r \le n.

출력

For each query of the second type, print the answer on a separate line. Answers should be printed in the same order as queries.