- Time limit: 1.00 s
- Memory limit: 512 MB
There is an array of numbers, indexed . Your task is to implement a data structure which has the following operators:
- Increase every number in the range by
- Set every number in the range to be
- Compute the sum of numbers in the range
Input
The first line of the input has single integer , the size of the array.
The next line has integers , the original content of the array.
Next line has single integer , the number of queries.
The rest lines each describe one query:
If the query type is 1, the line is of form "1 ". This means that every number in the range needs to be increased by .
If the query type is 2, the line is of form "2 ". This means that every number in the range needs to be set to .
If the query type is 3, the line is of form "3 ". This means that you have to count the sum of numbers in the range .
Output
For each query of type 3, output the sum, one per line.
Limits
Example
Input:
5 2 3 1 1 5 5 3 3 5 1 2 4 2 3 3 5 2 2 4 5 3 3 5
Output:
7 11 15