Sum Of Range - Range Query Range Update
medium
You are given an array(of integers) of length n. You are required to answer q queries. Queries can be of two types 0. 0 l r : In this you have to return sum of all elements arr[i] for i in l
Constraints
1. 1 <= n, q <= 10^5 2. 0 <= l <= r < n 3. 10^4 <= arr[i], val <= 10^4.
Format
Input
A number n n1 n2 .. n number of elements A number q following q lines contains queries of format either of two 0 l r, 1 l r val
Output
for each query of type 0 print a single integer in seperate line
Example
Sample Input
8
0
10
10
-1
5
8
10
2
5
0 7 7
1 4 6 1
0 2 4
1 5 5 7
0 3 7
Sample Output
2
15
34