Harry, Ron and Hermione decide to take part in this year's ACM ICPC and show the world that they are excellent in coding as well. So they start preparing for the contest at full throttle.
They encounter an interesting problem. Since you also seem to be interested in ACM ICPC, let's see if you can solve this problem quicker than them. The problem is about an array, a, and some operations which are to be performed on the array. The array contains unsigned integers of size 4 bytes. The operations performed on the array are :
Your time begins now! Let's see if you can defeat Harry, Ron and Hermione or not!
Input:
First line of the input contains an integer n, the size of the array.
The next line contains n space separated integers, ai, the elements of the array.
The next line contains an integer q, the number of operations to be performed on the array.
The next q lines describe the q operations to be performed.
For each operation, the first input is an integer type, the type of the operation to be performed.
- If type=1, three integers follow, l, r and k, which are the same as those defined for the Blip operation. You need to perform the Blip operation for the given values of l, r and k in this operation.
- If type=2, two integers follow, l and r, which are the same as described for Flip operation. You need to perform the Flip operation for the given values of l and r in this operation.
- If type=3, two integers follow, l and r, which are the same as described for Tell operation. You need to perform the Tell operation for the given values of l and r in this operation.
Output:
For each Tell operation, print the result of the operation, i.e. the sum of the array elements in the range [l,r] in a separate line.
Constraints:
1 ≤ n ≤ 105
0 ≤ ai < 232
1 ≤ q ≤ 105
type ∈ {1,2,3}
0 ≤ l ≤ r < n
0 ≤ k ≤ 109
Additional constraints for 20 points:
1 ≤ n ≤ 1000
1 ≤ q ≤ 1000
Note: The elements of the array are of the type unsigned Integer of size 4 bytes.
Setter - Sahil Prakash
For the first query, answer will be 1+2+4+8 = 15.
Array after the second query: [2147483648, 1, 4, 8]
Array after the third query: [2147483648, 1, 4294967291, 4294967287]
Answer for the fourth query: 2147483648+1+4294967291+4294967287 = 10737418227