#P1438. 无聊的数列

无聊的数列

Description

Maintain a sequence aia_i supporting two operations:

  • 1 l r K D: You are given an arithmetic progression of length rl+1r - l + 1 with first term KK and common difference DD, and you add it correspondingly to each number in the range [l,r][l, r]. Specifically: let $a_l=a_l+K,a_{l+1}=a_{l+1}+K+D\ldots a_r=a_r+K+(r-l) \times D$.

  • 2 p: Query the value of the pp-th element apa_p.

Input Format

The first line contains two integers n,mn, m denoting the length of the sequence and the number of operations.

The second line contains nn integers, where the ii-th number is aia_i.

Each of the next mm lines starts with an integer optopt.

If opt=1opt = 1, then four more integers l r K Dl\ r\ K\ D follow.

If opt=2opt = 2, then one more integer pp follows.

Output Format

For each query, output one integer per line representing the answer.

5 2
1 2 3 4 5
1 2 4 1 2
2 3

6

Hint

Constraints

For 100%100\% of the testdata, $0\le n,m \le 10^5,-200\le a_i,K,D\le 200, 1 \leq l \leq r \leq n, 1 \leq p \leq n$.

Translated by ChatGPT 5