Given an array of size , support the of the following operations:
- Find the maximum prefix sum of the subarray from index to index . That is, find the maximum sum of a subarray starting at and ending in the range .
- Update the element at index to value .
Constraints
Input Specification
The first line contains integers and .
The second line contains integers , the initial elements of .
The next lines are one of two forms:
P l r
representing the first operation.U i x
representing the second operation.
Output Specification
For each type operation output one integer on its own line, the answer to that query.
Sample Input
7 5
-1 3 2 -6 5 -6 7
P 2 6
P 5 7
U 4 -3
P 2 6
P 1 1
Sample Output
5
6
7
-1
Comments