Given an array of integers with size n. Answer m queries.
The first line of the input contains an integer n. The next line has n integers. The third line has m, and the following m lines have queries in the format mentioned below.
Type Description
1 l r Add integers 1,2,3 , ......., r-l+1 to elements from index l to r respectively
2 x Print the element at index x
Sample Input
10
1 3 4 1 1 2 7 1 3 9
5
2 3
1 2 4
2 4
1 2 8
2 4
Sample Output
4
4
7
Explanation
The first query asks for the value at position 3, which is 4
The second query asks to add 1, 2, 3 to positions 2, 3, 4, respectively, so the array becomes
1 4 6 4 1 2 7 1 3 9
The third query asks for the fourth element, which is 4
The fourth query asks to add 1, 2, ....., 7 to positions 2, 3, ...., 8 respectively, so the array becomes
1 5 8 7 5 7 13 8 8 9
The fifth query asks for the fourth element, which is 7
PS: Solutions with O(n^2) complexity gave TLE.