Bob has a sequence of integers of length
, indexed from
to
. Bob will perform
operations on this array. Each operation is one of the following two types:
0 L R x
: For all indicessuch that
, Bob updates
as
1 L R
: Bob wants to find the maximum subarray sum in the range. That is, you must find the maximum possible sum of a subarray
where
. Additionally, Bob allows empty subarrays, and their sum is considered to be 0.
Input
The first line of input contains two integers (
) and
(
), the number of elements in the array and the number of operations.
The second line of input contains integers
, (
), representing the original array.
Each of the following lines contains one operation in one of the two formats
0 L R x
or 1 L R
.
Output
For every 1 L R
operation, output a single line containing the answer to the maximum subarray sum query.
Constraints
Subtask | Points | Additional constraints |
---|---|---|
No additional constraints |
Sample Input
5 7
2 -4 6 -5 5
1 1 5
0 1 5 -4
1 1 5
0 3 4 -1
1 1 5
0 1 3 -1
1 1 5
Sample Output
6
7
10
11
Explanation for Sample
- For the
st query, the largest subarray sum is
.
- For the
nd query, the array changes to
and the max subarray sum is
.
- For the
rd query, the array changes to
and the max subarray sum is
.
- For the
th query, the array changes to
and the max subarray sum is
.
Comments